Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitde2f42e

Browse files
jaaydenhspikecurtisBrunoQuaresma
authored
fix: enable Tailwind with storybook (#15418)
This adds index.css to the storybook preview file and references to#storybook-root element in the tailwind config---------Co-authored-by: Spike Curtis <spike@coder.com>Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
1 parentcb9991a commitde2f42e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

‎site/.storybook/preview.jsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Storybook decorator function used to inject baseline data dependencies into
1717
* our React components during testing.
1818
*/
19+
import"../src/index.css";
1920
import{ThemeProviderasEmotionThemeProvider}from"@emotion/react";
2021
importCssBaselinefrom"@mui/material/CssBaseline";
2122
import{
@@ -134,6 +135,12 @@ function withTheme(Story, context) {
134135
const{ themeOverride}=DecoratorHelpers.useThemeParameters();
135136
constselected=themeOverride||selectedTheme||"dark";
136137

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")?.setAttribute("class",selected);
143+
137144
return(
138145
<StrictMode>
139146
<StyledEngineProviderinjectFirst>

‎site/tailwind.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = {
55
},
66
darkMode:["selector"],
77
content:["./index.html","./src/**/*.{js,ts,jsx,tsx}"],
8-
important:"#root",
8+
important:["#root","#storybook-root"],
99
theme:{
1010
fontSize:{
1111
"2xs":["0.626rem","0.875rem"],

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp