A Storybook addon for switching different themes (ex. daisyUI etc.)
npm install storybook-addon-theme-changerThis addon just controls themes (for example, light and dark), just adding data-theme attribute to the html tag.
It works nicely with UI libraries such as daisyUI.
Support Storybook 8
Add this addon to the .storybook/main.js (main.ts) file.
``{javascript}`
module.exports = {
...
addons: [
// your addons here
"storybook-addon-theme-changer"
],
};
Add your themes to the .storybook/preview.js (preview.ts) file
`{javascript}`
...
export const globalTypes = {
themes: {
defaultValue: [
"light",
"dark",
...
],
},
or
`{javascript}``
...
export const globals = {
themes: [
"light",
"dark",
...
],
},