Storybook: how do you enable withKnobs as a global?

Created on 8 Sep 2017  路  9Comments  路  Source: storybookjs/storybook

I can't seem to get this to work globally?

knobs inactive question / support

Most helpful comment

Do you have these files configured:

config.js

import { addDecorator } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';

addDecorator(withKnobs);

addons.js

import '@storybook/addon-knobs/register'

All 9 comments

Do you have these files configured:

config.js

import { addDecorator } from '@storybook/react';
import { withKnobs } from '@storybook/addon-knobs';

addDecorator(withKnobs);

addons.js

import '@storybook/addon-knobs/register'

Not working for me either, I see the knobs pane but nothing in it. Have the config.js and addons.js as noted.

Can you please share an example of the story file where you want to use knobs ?

Pretty simple stuff:

import React from 'react';
import { storiesOf } from '@storybook/react';

import Avatar from './index';

const stories = storiesOf('Avatar', module);

stories.add('[email protected]', () => {
  return <Avatar email="[email protected]" />;
});

Perhaps I'm assuming that the decorator will simply enable all component props as knobs? If this isn't true, is it something that can be accomplished?

There is a smart knobs addon that does this: https://github.com/storybooks/addon-smart-knobs
Otherwise you need to define each property separately: https://github.com/storybooks/storybook/tree/master/addons/knobs

Great! Thanks @igor-dv, I'll look into it.

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. We do try to do some housekeeping every once in a while so inactive issues will get closed after 90 days. Thanks!

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Was this page helpful?
0 / 5 - 0 ratings