Closed rick-liyue-huang closed 3 weeks ago
To resolve the issue with Tailwind CSS presets not working in Storybook, follow these steps:
.storybook/preview.js
:import { Preview } from '@storybook/react';
+import '../src/index.css';
const preview: Preview = {
parameters: { /* ... */ },
};
export default preview;
tailwind.config.js
:import * as uiCoreConfig from 'project-one';
/** @type {import('tailwindcss').Config} */
export default {
presets: [uiCoreConfig],
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
},
plugins: [],
};
.storybook/main.js
:export default {
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
addons: [
'@storybook/addon-essentials',
+ '@storybook/addon-themes',
],
};
withThemeByClassName
decorator in .storybook/preview.js
:import { Preview, Renderer } from '@storybook/react';
+import { withThemeByClassName } from '@storybook/addon-themes';
import '../src/index.css';
const preview: Preview = {
parameters: { /* ... */ },
+ decorators: [
+ withThemeByClassName<Renderer>({
+ themes: {
+ light: '',
+ dark: 'dark',
+ },
+ defaultTheme: 'light',
+ }),
+ ]
};
export default preview;
/code/addons/themes/docs/getting-started/tailwind.md /code/.storybook/preview.tsx /code/.storybook/main.ts
Hi, thanks for reporting this. do you have a reproduction repo you can share? If not, can you please create one via storybook.new? We prioritize bug reports that have reproduction. Thank you! ๐
Hi there! Thank you for opening this issue, but it has been marked as stale
because we need more information to move forward. Could you please provide us with the requested reproduction or additional information that could help us better understand the problem? We'd love to resolve this issue, but we can't do it without your help!
I'm afraid we need to close this issue for now, since we can't take any action without the requested reproduction or additional information. But please don't hesitate to open a new issue if the problem persists โ we're always happy to help. Thanks so much for your understanding.
Describe the bug
I create two vite react tailwindcss storybook project, project-one and project-two, I created the customized style in project-one tailwind.config.js, and export it to project two in project-two, I define the tailwind.config.js as:
Additional context
No response