Introduction to Design Systems


Storybook has an add-on called knobs which allows you to interact with your components and change their proprerties in real-time.

First let's install knobs with the following command.

npm i -D @storybook/addon-knobs

Next we have to add the add-on to the Storybook configuration in main.js.

module.exports = {
  stories: ["../src/**/*.stories.(js|mdx)"],
  addons: [

We also need to tell Storybook to use withKnobs as a decorator. Inside preview.js, import withKnobs and add it as a decorator.

import { withKnobs } from "@storybook/addon-knobs";


Let's add a knob for setting the disabled state of our buttons. Inside Button.stories.mdx import the following.

import { withKnobs, boolean } from "@storybook/addon-knobs";

Then we can add the disabled attribute to our button using the boolean value we just imported.

<Preview withToolbar>
  <Story name="primary">
    <PrimaryButton disabled={boolean("Disabled", false)}>
      Hello world

After restarting your storybook server, head back to your UI, under the canvas tab, you should see a knob at the bottom with a checkbox discerning the disabled state. If you click it, it should disable the button.