Skip to content

Commit 8203a3c

Browse files
BrunoQuaresmajaaydenh
authored andcommitted
Apply theme selector
1 parent 58131f2 commit 8203a3c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

site/.storybook/preview.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ function withTheme(Story, context) {
135135
const { themeOverride } = DecoratorHelpers.useThemeParameters();
136136
const selected = themeOverride || selectedTheme || "dark";
137137

138+
// Ensure the correct theme is applied to Tailwind CSS classes by adding the
139+
// theme to the HTML class list. This approach is necessary because Tailwind
140+
// CSS relies on class names to apply styles, and dynamically changing themes
141+
// requires updating the class list accordingly.
142+
document.querySelector("html")?.classList.add(selected);
143+
138144
return (
139145
<StrictMode>
140146
<StyledEngineProvider injectFirst>

0 commit comments

Comments
 (0)