docs/api/parameters.mdx
Parameters are static metadata used to configure your stories and addons in Storybook. They are specified at the story, meta (component), project (global) levels.
Parameters specified at the story level apply to that story only. They are defined in the parameters property of the story (named export):
Parameters specified at the story level will override those specified at the project level and meta (component) level.
</Callout>Parameter's specified in a CSF file's meta configuration apply to all stories in that file. They are defined in the parameters property of the meta (or default export):
Parameters specified at the meta (component) level will override those specified at the project level.
</Callout>Parameters specified at the project (global) level apply to all stories in your Storybook. They are defined in the parameters property of the meta (or default export) in your .storybook/preview.* file:
Storybook only accepts a few parameters directly.
layoutType: 'centered' | 'fullscreen' | 'padded'
Default: 'padded'
Specifies how the canvas should lay out the story.
htmlLangType: string
Default: 'en'
A BCP-47 language tag (e.g. 'ja', 'de', 'fr-CH') describing the language of the rendered story UI. In story view it sets the lang attribute on the preview's <html> element; in docs view it sets lang on each embedded story canvas. Inherited project → meta → story.
Use this to language the components you render — for example, a German story added for copy-length validation inside an otherwise English design system.
Storybook's own interface (the manager UI and docs chrome such as toolbars and ArgTypes headers) always reports as English and is unaffected by this parameter.
docs.langType: string
Default: 'en'
A BCP-47 language tag describing the language of the docs prose that Storybook renders — component and story descriptions, ArgTypes description cells, and free-form MDX prose. Resolved project → meta for page-level content and project → meta → story for per-story content.
This is independent of htmlLang: the language you document in can differ from the language your stories render in. Storybook chrome (toolbars, ArgTypes column headers, anchor links) stays English regardless.
optionsType:
{
storySort?: StorySortConfig | StorySortFn;
}
The options parameter can only be applied at the project level.
options.storySortType: StorySortConfig | StorySortFn
type StorySortConfig = {
includeNames?: boolean;
locales?: string;
method?: 'alphabetical' | 'alphabetical-by-kind' | 'custom';
order?: string[];
};
type Story = {
id: string;
importPath: string;
name: string;
title: string;
};
type StorySortFn = (a: Story, b: Story) => number;
Specifies the order in which stories are displayed in the Storybook UI.
When specifying a configuration object, the following options are available:
false.alphabetical.
['Intro', 'Pages', ['Home', 'Login', 'Admin'], 'Components'].When specifying a custom sorting function, the function behaves like a typical JavaScript sorting function. It accepts two stories to compare and returns a number. For example:
(a, b) => (a.id === b.id ? 0 : a.id.localeCompare(b.id, undefined, { numeric: true }));
See the guide for usage examples.
testType:
{
clearMocks?: boolean;
mockReset?: boolean;
restoreMocks?: boolean;
dangerouslyIgnoreUnhandledErrors?: boolean;
}
clearMocksType: boolean
Default: false
Similar to Vitest, it will call .mockClear() on all spies created with fn() from storybook/test when a story unmounts. This will clear mock history, but not reset its implementation to the default one.
mockResetType: boolean
Default: false
Similar to Vitest, it will call .mockReset() on all spies created with fn() from storybook/test when a story unmounts. This will clear mock history and reset its implementation to an empty function (will return undefined).
restoreMocksType: boolean
Default: true
Similar to Vitest, it will call .restoreMocks() on all spies created with fn() from storybook/test when a story unmounts. This will clear mock history and reset its implementation to the original one.
dangerouslyIgnoreUnhandledErrorsType: boolean
Default: false
Unhandled errors might cause false positive assertions. Setting this to true will prevent the play function from failing and showing a warning when unhandled errors are thrown during execution.
All other parameters are contributed by features. The essential feature's parameters are documented on their individual pages:
No matter where they're specified, parameters are ultimately applied to a single story. Parameters specified at the project (global) level are applied to every story in that project. Those specified at the meta (component) level are applied to every story associated with that meta. And parameters specified for a story only apply to that story.
When specifying parameters, they are merged together in order of increasing specificity:
Parameters are merged, so objects are deep-merged, but arrays and other properties are overwritten.
</Callout>In other words, the following specifications of parameters:
const preview = {
// 👇 Project-level parameters
parameters: {
layout: 'centered',
demo: {
demoProperty: 'a',
demoArray: [1, 2],
},
},
// ...
};
export default preview;
const meta = {
component: Dialog,
// 👇 Meta-level parameters
parameters: {
layout: 'fullscreen',
demo: {
demoProperty: 'b',
anotherDemoProperty: 'b',
},
},
};
export default meta;
// (no additional parameters specified)
export const Basic = {};
export const LargeScreen = {
// 👇 Story-level parameters
parameters: {
layout: 'padded',
demo: {
demoArray: [3, 4],
},
},
};
Will result in the following parameter values applied to each story:
// Applied story parameters
// For the Basic story:
{
layout: 'fullscreen',
demo: {
demoProperty: 'b',
anotherDemoProperty: 'b',
demoArray: [1, 2],
},
}
// For the LargeScreen story:
{
layout: 'padded',
demo: {
demoProperty: 'b',
anotherDemoProperty: 'b',
demoArray: [3, 4],
},
}