How do I make the canvas background color change, when a theme is selected? #25183
Replies: 3 comments 10 replies
-
Thanks for taking the time to reach out to us with your question. We appreciate it 🙏 ! So that you're aware, the styling addon you referred to is officially [deprecated}(https://storybook.js.org/addons/@storybook/addon-styling), and we're encouraging users to use one of the alternatives provided in the disclaimer (ie., Looking forward to hearing from you. Hope you have a great day. Stay safe |
Beta Was this translation helpful? Give feedback.
-
Using Tailwind with add on-theme, my preference is to use |
Beta Was this translation helpful? Give feedback.
-
There is actually a quite easy way to do this, with themes addon alone: export const decorators = [
withThemeByClassName({
themes: {
light: "light",
dark: "dark bg-neutral-900",
},
defaultTheme: "light",
}),
] Just add Tailwind background class as part of your themes css classes list. Be mindful that in Might be worth also disabling backgrounds in your preview config: const preview: Preview = {
parameters: {
backgrounds: { disable: true },
}
} as they will be conflicting with your theme classes. |
Beta Was this translation helpful? Give feedback.
-
Summary
I'm using Sveltekit and Tailwind, and followed the guide here to add the "theme" selector:
My question is, how can I make the background color of the canvas change to a dark tailwind class, when dark-mode is selected? Thanks 🙏
Additional information
No response
Create a reproduction
No response
Beta Was this translation helpful? Give feedback.
All reactions