Storybook is a tool for UI development. It makes development faster and easier by isolating components. This allows you to work on one component at a time.
You can develop entire UIs without needing to start up a complex dev stack, force certain data into your database, or navigate around your application.
Write docs with MDX
// Checkbox.stories.mdx
import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
import { Checkbox } from './Checkbox';
<Meta title="MDX/Checkbox" component={Checkbox} />
With MDX
we can define a story for Checkbox
right in the middle of our
Markdown documentation.
// This is your Story template function, shown here in React
// Checkbox
export const Template = (args) => <Checkbox {...args} />
<Canvas>
<Story name="Unchecked" args={{
label: 'Unchecked'
}}>
{Template.bind({})}
</Story>
<Story name="Checked" args={{
label: 'Unchecked',
checked: true
}}>
{Template.bind({})}
</Story>
<Story name="Secondary" args={{
label: 'Secondary',
checked: true,
appearance: 'secondary'
}}>
{Template.bind({})}
</Story>
</Canvas>
And here’s how that’s rendered in Storybook: