Frequently Asked Questions

Here are some answers to frequently asked questions. If you have a question, you can ask it in our GitHub discussions.

Error: No angular.json file found

Storybook can be set up for both single-project and multi-project Angular workspaces. To set up Storybook for a project, run npx storybook@latest init at the root of the workspace where the angular.json file is located. During initialization, the .storybook folder will be created and the angular.json file will be edited to add the Storybook configuration for the selected project. It's important to run the command at the root level to ensure that Storybook detects all projects correctly.

How can I opt-out of Angular Ivy?

In case you are having trouble with Angular Ivy you can deactivate it in your main.js:

Loading...

How can I opt-out of Angular ngcc?

In case you postinstall ngcc, you can disable it:

Loading...

Please report any issues related to Ivy in our GitHub Issue Tracker as the support for View Engine will be dropped in a future release of Angular.

How can I run coverage tests with Create React App and leave out stories?

Create React App does not allow providing options to Jest in your package.json, however you can run jest with commandline arguments:

Loading...

If you're using Yarn as a package manager, you'll need to adjust the command accordingly.

How do I setup Storybook to share Webpack configuration with Next.js?

You can generally reuse Webpack rules by placing them in a file that is require()-ed from both your next.config.js and your .storybook/main.js files. For example:

Loading...

How do I fix module resolution in special environments?

In case you are using Yarn Plug-n-Play or your project is set up within a mono repository environment, you might run into issues with module resolution similar to this when running Storybook:

Terminal
Loading...

To fix this, you can wrap the package name inside your Storybook configuration file (i.e., .storybook/main.js|ts) as follows:

How do I setup the new React Context Root API with Storybook?

If your installed React Version equals or is higher than 18.0.0, the new React Root API is automatically used and the newest React concurrent features can be used.

You can opt-out from the new React Root API by setting the following property in your .storybook/main.js file:

Loading...

Why is there no addons channel?

A common error is that an addon tries to access the "channel", but the channel is not set. It can happen in a few different cases:

  1. You're trying to access addon channel (e.g., by calling setOptions) in a non-browser environment like Jest. You may need to add a channel mock:

    Loading...
  2. In React Native, it's a special case documented in #1192

Why aren't Controls visible in the Canvas panel but visible in Docs?

If you're adding Storybook's dependencies manually, make sure you include the @storybook/addon-controls dependency in your project and reference it in your .storybook/main.js as follows:

.storybook/main.js
Loading...

Why aren't the addons working in a composed Storybook?

Composition is a new feature that we released with version 6.0, and there are still some limitations to it.

For now, the addons you're using in a composed Storybook will not work.

We're working on overcoming this limitation, and soon you'll be able to use them as if you are working with a non-composed Storybook.

Can I have a Storybook with no local stories?

Storybook does not work unless you have at least one local story (or docs page) defined in your project. In this context, local means a .stories.* or .mdx file that is referenced in your project's .storybook/main.js config.

If you're in a Storybook composition scenario, where you have multiple Storybooks, and want to have an extra Storybook with no stories of its own, that serves as a "glue" for all the other Storybooks in a project for demo/documentation purposes, you can do the following steps:

Introduce a single .mdx docs page (addon-essentials or addon-docs required), that serves as an Introduction page, like so:

Introduction.mdx
Loading...

And then refer to it in your Storybook config file:

.storybook/main.js
Loading...

Which community addons are compatible with the latest version of Storybook?

Starting with Storybook version 6.0, we've introduced some great features aimed at streamlining your development workflow.

With this, we would like to point out that if you plan on using addons created by our fantastic community, you need to consider that some of those addons might be working with an outdated version of Storybook.

We're actively working to provide a better way to address this situation, but in the meantime, we'd like to ask for a bit of caution on your end so that you don't run into unexpected problems. Let us know by leaving a comment in the following GitHub issue so that we can gather information and expand the current list of addons that need to be updated to work with the latest version of Storybook.

Is it possible to browse the documentation for past versions of Storybook?

With the release of version 6.0, we updated our documentation as well. That doesn't mean that the old documentation was removed. We kept it to help you with your Storybook migration process. Use the content from the table below in conjunction with our migration guide.

We're only covering versions 5.3 and 5.0 as they were important milestones for Storybook. If you want to go back in time a little more, you'll have to check the specific release in the monorepo.

SectionPageCurrent LocationVersion 5.3 locationVersion 5.0 location
N/AWhy StorybookSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Get startedInstallSee current documentationSee versioned documentationSee versioned documentation
What's a storySee current documentationSee versioned documentation for your frameworkSee versioned documentation for your framework
Browse StoriesSee current documentationSee versioned documentation for your frameworkSee versioned documentation for your framework
SetupSee current documentationSee versioned documentation for your frameworkSee versioned documentation for your framework
Write storiesIntroductionSee current documentationSee versioned documentationSee versioned documentation
ParametersSee current documentationSee versioned documentationNon existing feature or undocumented
DecoratorsSee current documentationSee versioned documentationSee versioned documentation
Naming components and hierarchySee current documentationSee versioned documentationSee versioned documentation
Build pages and screensSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Stories for multiple componentsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Write docsAutodocsSee current documentationSee versioned addon documentationNon existing feature or undocumented
MDXSee current documentationSee versioned addon documentationNon existing feature or undocumented
Doc BlocksSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Preview and build docsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
TestingVisual testsSee current documentationSee versioned documentationSee versioned documentation
Accessibility testsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Interaction testsSee current documentationSee versioned documentationSee versioned documentation
Snapshot testsSee current documentationSee versioned documentationSee versioned documentation
Import stories in tests/Unit testsSee current documentationSee versioned documentationSee versioned documentation
Import stories in tests/End-to-end testingSee current documentationSee versioned documentationSee versioned documentation
SharingPublish StorybookSee current documentationSee versioned documentationSee versioned documentation
EmbedSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
CompositionSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Package CompositionSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Essential addonsControlsSee current documentationControls are specific to version 6.0 see Knobs versioned documentationControls are specific to version 6.0 see Knobs versioned documentation
ActionsSee current documentationSee addon versioned documentationSee addon versioned documentation
ViewportSee current documentationSee addon versioned documentationSee addon versioned documentation
BackgroundsSee current documentationSee addon versioned documentationSee addon versioned documentation
Toolbars and globalsSee current documentationSee versioned documentationNon existing feature or undocumented
ConfigureOverviewSee current documentationSee versioned documentationSee versioned documentation
Integration/FrameworksSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Integration/Framework support for frameworksSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Integration/CompilersSee current documentationSee versioned documentation hereSee versioned documentation here
Integration/TypescriptSee current documentationSee versioned documentationSee versioned documentation
Integration/Styling and CSSSee current documentationSee versioned documentationSee versioned documentation
Integration/Images and assetsSee current documentationSee versioned documentationSee versioned documentation
Story renderingSee current documentationSee versioned documentation here and hereSee versioned documentation here
Story LayoutSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
User Interface/Features and behaviorSee current documentationSee versioned documentationSee versioned documentation
User Interface/ThemingSee current documentationSee versioned documentationSee versioned documentation
User Interface/Sidebar & URLSSee current documentationSee versioned documentationSee versioned documentation
Environment variablesSee current documentationSee versioned documentationSee versioned documentation
BuildersIntroductionSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
ViteSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
WebpackSee current documentationSee versioned documentationSee versioned documentation
Builder APISee current documentationNon existing feature or undocumentedNon existing feature or undocumented
AddonsIntroductionSee current documentationSee versioned documentationSee versioned documentation
Install addonsSee current documentationSee versioned documentationSee versioned documentation
Writing AddonsSee current documentationSee versioned documentationSee versioned documentation
Writing PresetsSee current documentationSee versioned documentationNon existing feature or undocumented
Addons Knowledge BaseSee current documentationSee versioned documentationSee versioned documentation
Types of addonsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Addons APISee current documentationSee versioned documentationSee versioned documentation
API@storybook/blocks/ArgTypesSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/CanvasSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/ColorPaletteSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/ControlsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/DescriptionSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/IconGallerySee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/MarkdownSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/MetaSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/PrimarySee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/SourceSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/StoriesSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/StorySee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/SubtitleSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/TitleSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/TypesetSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/UnstyledSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
@storybook/blocks/useOfSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
Stories/Component Story Format (see note below)See current documentationSee versioned documentationNon existing feature or undocumented
ArgTypesSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/OverviewSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/frameworkSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/storiesSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/addonsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/babelSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/babelDefaultSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/buildSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/coreSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/docsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/envSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/featuresSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/indexersSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/logLevelSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/managerHeadSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/previewAnnotationsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/previewBodySee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/previewHeadSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/refsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/staticDirsSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/swcSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/typescriptSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/viteFinalSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
main.js configuration/webpackFinalSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
FrameworksSee current documentationNon existing feature or undocumentedNon existing feature or undocumented
CLI optionsSee current documentationSee versioned documentationSee versioned documentation

If you have stories written with the older storiesOf format, it was removed in Storybook 8.0 and is no longer maintained. We recommend that you migrate your stories to CSF. See the migration guide for more information. However, if you need, you can still access the old storiesOf documentation for reference.

What icons are available for my toolbar or my addon?

With the @storybook/components package, you get a set of icons that you can use to customize your UI. Use the table below as a reference while writing your addon or defining your Storybook global types. Go through this story to see how the icons look.

I see a "No Preview" error with a Storybook production build

If you're using the serve package to verify your production build of Storybook, you'll get that error. It relates to how serve handles rewrites. For instance, /iframe.html is rewritten into /iframe, and you'll get that error.

We recommend that you use http-server instead and use the following command to preview Storybook:

Terminal
Loading...

Suppose you don't want to run the command above frequently. Add http-server as a development dependency and create a new script to preview your production build of Storybook.

Can I use Storybook with Vue 2?

Vue 2 entered End of Life (EOL) on December 31, 2023, and is no longer supported by the Vue team. As a result, we've stopped supporting Vue 2 in Storybook 8 and above and will not be releasing any new versions that support it. We recommend upgrading your project to Vue 3, which Storybook fully supports. If that's not an option, you can still use Storybook with Vue 2 by installing the latest version of Storybook 7 with the following command:

Why aren't my code blocks highlighted with Storybook MDX?

Out of the box, Storybook provides syntax highlighting for a set of languages (e.g., Javascript, Markdown, CSS, HTML, Typescript, GraphQL) you can use with your code blocks. Currently, there's a known limitation when you try to register a custom language to get syntax highlighting. We're working on a fix for this and will update this section once it's available.

Why aren't my MDX styles working in Storybook?

Writing documentation with MDX can be troublesome, especially regarding how your code is formatted when using line breaks with code blocks. For example, this will break:

Loading...

But this will work:

Loading...

See the following issue for more information.

Why are my mocked GraphQL queries failing with Storybook's MSW addon?

If you're working with Vue 3, you'll need to install @vue/apollo-composable. With Svelte, you'll need to install @rollup/plugin-replace and update your rollup.config file to the following:

rollup.config
Loading...

With Angular, the most common issue is the placement of the mockServiceWorker.js file. Use this example as a point of reference.

Can I use other GraphQL providers with Storybook's MSW addon?

Yes, check the addon's examples to learn how to integrate different providers.

Can I mock GraphQL mutations with Storybook's MSW addon?

No, currently, the MSW addon only has support for GraphQL queries. If you're interested in including this feature, open an issue in the MSW addon repository and follow up with the maintainer.

How can my code detect if it is running in Storybook?

You can do this by checking for the IS_STORYBOOK global variable, which will equal true when running in Storybook. The environment variable process.env.STORYBOOK is also set to true.

Why are my stories not showing up correctly when using certain characters?

Storybook allows you to use most characters while naming your stories. Still, specific characters (e.g., #) can lead to issues when Storybook generates the internal identifier for the story, leading to collisions and incorrectly outputting the correct story. We recommend using such characters sparsely.

Why is Storybook's source loader returning undefined with curried functions?

This is a known issue with Storybook. If you're interested in getting it fixed, open an issue with a working reproduction so that it can be triaged and fixed in future releases.

Why are my args no longer displaying the default values?

Before version 6.3, unset args were set to the argTypes.defaultValue if specified or inferred from the component's properties (e.g., React's prop types, Angular inputs, Vue props). Starting with version 6.3, Storybook no longer infers default values but instead defines the arg's value as undefined when unset, allowing the framework to supply its default value.

If you are using argTypes.defaultValue to fix the above, you no longer need to, and you can safely remove it from your stories.

Additionally, suppose you were using argTypes.defaultValue or relying on inference to set a default value for an arg. In that case, you should define the arg's value at the component level instead:

MyComponent.stories.js
Loading...

For Storybook's Docs, you can manually configure the displayed value by configuring the table.defaultValue setting:

MyComponent.stories.js
Loading...

Why isn't Storybook's test runner working?

There's an issue with Storybook's test runner and the latest version of Jest (i.e., version 28), which prevents it from running effectively. As a workaround, you can downgrade Jest to the previous stable version (i.e., version 27), and you'll be able to run it. See the following issue for more information.

How does Storybook handle environment variables?

Storybook has built-in support for environment variables. By default, environment variables are only available in Node.js code and are not available in the browser as some variables should be kept secret (e.g., API keys) and not exposed to anyone visiting the published Storybook.

To expose a variable, you must preface its name with STORYBOOK_. So STORYBOOK_API_URL will be available in browser code but API_KEY will not. Additionally you can also customize which variables are exposed by setting the env field in the .storybook/main.js file.

Variables are set when JavaScript is compiled so when the development server is started or you build your Storybook. Environment variable files should not be committed to Git as they often contain secrets which are not safe to add to Git. Instead, add .env.* to your .gitignore file and set up the environment variables manually on your hosting provider (e.g., GitHub).

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,613 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