storybookjs / addon-knobs

Storybook addon prop editor component
MIT License
12 stars 17 forks source link

Sharing knob values across stories #8

Open Firebrand opened 3 years ago

Firebrand commented 3 years ago

I've scoured the forum here as well as resources online, but can't seem to find an answer. How would I go about sharing knob values across different COMPONENTS? (ex. User navigates to a button component in Storybook and chooses to make it green, they then navigate to a form component -which includes the prev button as a subcomponent- and the button in there appears green).

I do not wish to use Storybook Controls as they do not support groups and thus make the interface very cumbersome for components with many settings.

Thanks so much guys!

shilman commented 3 years ago

FYI, we’ve released addon-controls in Storybook 6.0. Controls are portable, auto-generated knobs that are intended to replace addon-knobs, which are slated for deprecation.

Please upgrade and try out controls today!

Regarding your question, controls are based on something called args: https://storybook.js.org/blog/introducing-storybook-args/

Args are designed to be re-used and composed across stories: https://storybook.js.org/docs/react/writing-stories/args#args-composition

Firebrand commented 3 years ago

@shilman I really appreciate your response. I have edited my original post. Cheers.