Addon-controls: Add custom user-defined controls
See original GitHub issueWe are currently documenting our React components in Storybook, and decided to go straight to version 6.0 to make use of the new Args and Controls addons. During that work, we realised that the choice of controls is very limited.
Here are some examples:
- We want users to select from a pre-defined list of colors. The
"select"
control can only display text but we want to preview the color next to it. - We want users to select from a list of icons. The control should display a list of all icons and clicking on an icon selects it.
- One prop may allow for
string[]
, so we want to allow the user to add strings to the list, or remove existing strings.
Any chance to allow users to specify custom controls in argTypes
that are not built into addon-controls
?
Here’s how this could look like in React code, where ColorPicker
is a custom control we’d build:
const ColorPicker = ({ value, setValue }) => {
return (
<select value={value} onChange={setValue}>
<option>red</option>
<option>blue</option>
</select>
);
}
export default {
title: "ExampleComponent",
component: ExampleComponent,
argTypes: {
color: {
control: ColorPicker,
},
},
};
Issue Analytics
- State:
- Created 3 years ago
- Reactions:89
- Comments:28 (7 by maintainers)
Top Results From Across the Web
Controls - Storybook - JS.ORG
Customize the controls and interactive data to suit your exact needs. To use the Controls addon, you need to write your stories using...
Read more >Next-level component showcasing with Storybook controls
Learn about controls, a new Storybook addon that lets you dynamically interact with your React components for demo and testing purposes.
Read more >@storybook/addon-controls - npm
npm install @storybook/addon-controls -D # or yarn ... If you ONLY want to use custom argTypes , don't set a component .
Read more >Solved: Can I add custom controls into Confluence Addon Pr...
Register panel initialization through. AJS. · Inside handler the first patameter would be macro placeholder, and teh second is buttons array. · If ......
Read more >How to make interactive components in Storybook (ReactJS ...
You can make it even cooler by defining custom controls for each of ... Use propTypes and defaultProps in your components to get...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would also be interested in adding controls for args with nested properties.
is there any update on this? Thank you