Skip to content

Commit 34ca468

Browse files
committed
preserve the tailwind style tag on storybook
1 parent 82ee228 commit 34ca468

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/next/src/next-devtools/dev-overlay/components/shadow-portal.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export function ShadowPortal({ children }: { children: React.ReactNode }) {
3737
if (portalNode.current.shadowRoot === null) {
3838
shadowNode.current = portalNode.current.attachShadow({ mode: 'open' })
3939

40+
// Storybook injects the Tailwind style tag from .storybook/main.ts on each load.
41+
// When navigating to a different story, the injected style tag is removed within the iframe.
42+
// To re-inject the style tag, we need to call `unuse()` since the `use()` function only runs
43+
// once unless unused.
44+
if (process.env.STORYBOOK) {
45+
tailwindCss.unuse()
46+
}
47+
4048
// Injecting Tailwind to the Shadow DOM with Webpack style-loader.
4149
// The target is passed to the next-devtools-inject-tailwind.js file which runs on the browser.
4250
// x-ref: https://webpack.js.org/loaders/style-loader/#lazystyletag

0 commit comments

Comments
 (0)