Storybook stories¶
MDX pages: storybook-documentation.mdc. Form FlowSuccess / FlowError* assertions: front-conventions.mdc.
Do not convert existing stories in a drive-by.
Layout¶
The preview default is centered. Do not set layout: 'centered'.
Never set layout: 'padded'.
centered: #storybook-root is height: auto and min-height: 100vh, one 1rem inset. It stretches its children, so a width: 100% frame is the canvas width. Auto margins on the story frame center a short story and collapse once it is taller than the viewport, so the page scrolls and the snapshot starts at the top. That frame is flex: none. Do not set height: 100% on the frame.
fullscreen is viewport height, padding 0. The provider stretches the story to that frame. Do not add a View decorator to give it h-full or w-full. Set it on a screen, a layout, or a playground rendered in a screen container (*ContainerDecorator, *ContainerPreview).
A modal story stays centered. The canvas height follows the content. Do not add an h-full shell only to size the host. A story that asserts the sheet against the viewport sets fullscreen on that story: an auto-height host collapses the sheet.
Page color is the Storybook backgrounds control. light is the page token (--background-color-neutral-primary) and the default. dark is --background-color-fill-neutral-tertiary and wraps the story in ScopedTheme dark. A dark story sets globals: { backgrounds: { value: 'dark' } }. A dark StoryVariant cell keeps its own background.
Width¶
The product parent decides the story width. A w-full on the component does not: filling a column, a card, or a modal is not the page.
Bare, no width decorator: the component sets its own size, or does not depend on a parent width (a fixed width, a content-sized control, icon, badge, chip).
100% (withParentWidth('full'), StoryVariant width="full"): a page section, a page card laid out at the full width of the page, or viewport chrome (banner, navbar, bar, page header, footer).
400 (withParentWidth('small'), width="small"): everything else whose layout depends on a parent. That parent is a column, a card, or a modal — a row, a field, a picker, a list item, a title, a card that shares the line, a horizontal scroller whose pagination only shows inside the column. small is w-[400] max-w-full: 400 when the parent is wider, the parent when the viewport is under 400.
withParentWidth is the outermost decorator. A Variants gallery does not put it on meta: Default carries the decorator, each cell carries width. width defaults to auto and adds no class; omit it. Not on a story that is already fullscreen, except a banner in a flex-1 page shell: the shell keeps the viewport height, and the decorator is the banner width. A modal stays bare: the modal is the width.
Variants¶
One row: StoryVariants. No column shell. Several groups (Button) stack those rows. A width="full" cell takes the line. A width="small" cell is 400 and the next wraps beside it. Two cards side by side use align="start", so a flex-1 card does not grow to the taller one. No extra padding on the render. The canvas already has 1rem.
Default is the playground. Variants holds every state a prop can show, including Loading. One or two extra stories only for a state a prop cannot open (tooltip, popover, modal): a play opens it, and Chromatic stays on. Those stories are not named Flow.
A grid that ignores args sets parameters: { controls: { disable: true } }.
No decorator and no render whose only job is CSS (max-width, width, padding, a background band, centering). A real screen shell stays.
Flow¶
Prefix Flow for a test interaction past the displayed state (submit, a click that is not itself the state to snapshot).
parameters.chromatic.disableSnapshot only when that play ends on the same pixels as Default / Filled (callback only, modal closed). Vitest still runs the play. A Flow that lands on an error, a toast, a step, or a conditional layout stays snapshotted.
Sidebar¶
Export Default first. MDX-only canvases live in *.examples.stories.tsx (tags: ['!dev'], chromatic.disableSnapshot).
parameters.overview on Uimmo/Components/* only. Not on Uimmo/Patterns/<Name>, not on *.examples.stories.tsx.