Parameters

Parameters are static metadata used to configure your stories and addons in Storybook. They are specified at the story, meta (component), project (global) levels.

Story parameters

ℹ️ Parameters specified at the story level will override those specified at the project level and meta (component) level.

Parameters specified at the story level apply to that story only. They are defined in the parameters property of the story (named export):

Meta parameters

ℹ️ Parameters specified at the meta (component) level will override those specified at the project level.

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 (default export):

Project parameters

Parameters specified at the project (global) level apply to all stories in your Storybook. They are defined in the parameters property of the default export in your .storybook/preview.js|ts file:

Available parameters

Storybook only accepts a few parameters directly.

layout

Type: 'centered' | 'fullscreen' | 'padded'

Default: 'padded'

Specifies how the canvas should lay out the story.

  • centered: Center the story within the canvas
  • padded: (default) Add padding to the story
  • fullscreen: Show the story as-is, without padding

options

Type:

Loading...

The options parameter can only be applied at the project level.

options.storySort

Type: StorySortConfig | StorySortFn

Loading...

Specifies the order in which stories are displayed in the Storybook UI.

When specifying a configuration object, the following options are available:

  • includeNames: Whether to include the story name in the sorting algorithm. Defaults to false.
  • locales: The locale to use when sorting stories. Defaults to your system locale.
  • method: The sorting method to use. Defaults to alphabetical.
    • alphabetical: Sort stories alphabetically by name.
    • alphabetical-by-kind: Sort stories alphabetically by kind, then by name.
    • custom: Use a custom sorting function.
  • order: Stories in the specified order will be displayed first, in the order specified. All other stories will be displayed after, in alphabetical order. The order array can accept a nested array to sort 2nd-level story kinds, e.g. ['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:

Loading...

See the guide for usage examples.


Essential addons

All other parameters are contributed by addons. The essential addon's parameters are documented on their individual pages:

Parameter inheritance

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:

  1. Project (global) parameters
  2. Meta (component) parameters
  3. Story parameters

ℹ️ Parameters are merged, so objects are deep-merged, but arrays and other properties are overwritten.

In other words, the following specifications of parameters:

.storybook/preview.js|ts
Loading...
Dialog.stories.js|ts
Loading...

Will result in the following parameter values applied to each story:

Applied story parameters
Loading...

Was this page helpful?

Markdown accepted ([link text](url), _italic_, **bold**, etc). Your anonymous feedback will be posted publicly on GitHub.

✍️ Edit on GitHub – PRs welcome!
Storybook
Join the community
6,598 developers and counting
WhyWhy StorybookComponent-driven UI
DocsGuidesTutorialsChangelogTelemetryStatus
CommunityAddonsGet involvedBlog
ShowcaseExploreProjectsComponent glossary
Open source software
Storybook

Maintained by
Chromatic
Special thanks to Netlify and CircleCI