Auto-Docs โ
Auto-docs is Storybook's way to present all your stories for one component on one page, including a the controls panel.
Set up โ
pnpm exec storybook add @storybook/addon-docsnpx storybook add @storybook/addon-docsyarn storybook add @storybook/addon-docsbun x storybook add @storybook/addon-docsThe storybook add command handles registration for you. If you prefer doing it by hand, it's one line in main.ts โ for CSF Next projects also registered in the preview:
import type { StorybookConfig } from 'ember-storybook';
export default {
addons: ['@storybook/addon-docs'],
} satisfies StorybookConfig;import type { Preview } from 'ember-storybook';
export default {
tags: ['autodocs'],
} satisfies Preview;The autodocs tag generates a docs page for every component. Drop it to a per-file level if you want pages selectively.
Auto-Docs Layout โ
- Title, subtitle, description โ your
meta, plus JSDoc on the component. - Primary story โ rendered inline (the framework sets
docs.story.inlinefor you). - Element โ the HTML tag your component renders, with attributes.
- Component Signature - Your component signature (see below)
- All stories โ with the code that produced them.
Component Signature โ
Component signatures are turned into auto documentation and render these parts (if available):
Element- the HTML tag your component renders, with attributesArgs- the Controls table.Blocks- your named blocks (eg.<:header>,<:default>), their block params and links to subcomponents they yieldCSS Custom Properties- to list how you can customize the stylingPart- to add custom styles to subelementsSubcomponents- components yielded by block params (same structure as the main component)
The Source Panel โ
The code shown under each example isn't stringified args โ a source decorator reconstructs the actual component invocation from your render (or from the implicit invocation, with args as @named arguments), so what you read is what runs. To keep the panel open for all stories:
parameters: {
docs: {
codePanel: true,
},
}Writing Docs โ
A *.stories.gts file is the docs page: meta fields for structure, markdown in the file for prose. For full custom pages use the .mdx format โ the stories file exports, the MDX file imports and arranges them:
# Card
import { Primary } from './card.stories.gts';
import { Canvas } from '@storybook/addon-docs/blocks';
A surface for grouped content.
<Canvas of={Primary} />Storybook's docs writing guide covers MDX, Parameters.docs, and custom blocks; all of it applies here.