Skip to content

Storybook Angular dynamic theme switching using storybook-dark-mode #8191

Closed Answered by ParsaArvanehPA
mostmand asked this question in Q&A
Discussion options

You must be logged in to vote

When you build your Angular app with ng build, two files named dark.css and default.css are generated in the root of your bundled build of Angular project. However, this does not happen with Storybook build. This causes an error when you try to change the Storybook theme because the dark.css file is not found. The solution is to add your dark.css and default.css files as Storybook's static assets so that they are available when you build or serve Storybook. If you want to learn how to add static assets to your Storybook, please refer to this link.

I added this line to Storybook's main.ts file:

staticDirs: ['../src/styles/story-book-themes'], //👈 Configures the static asset folder in Story…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@mostmand
Comment options

@ParsaArvanehPA
Comment options

Comment options

You must be logged in to vote
1 reply
@mostmand
Comment options

Answer selected by mostmand
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants