Reputation: 849
*The following question is related to a previous question I asked, so apologies in advance if I'm being repetitive, but I still haven't been able to resolve my issue.
I'm trying to get Storybook to work with Tailwind CSS to no avail so far. These are the steps I've followed:
module.exports = {
"stories": [
"../stories/**/*.stories.mdx",
"../stories/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-postcss"
],
"framework": "@storybook/react"
}
Despite doing all these, I don't see any effect of Tailwind on the story components—only in the application.
I tried testing if Tailwind works by putting in a small element in a Storybook component. I don't see it rendered as expected:
<h1 className="text-3xl font-bold underline">
Tailwind Works!
</h1>
Link to Github repo: https://github.com/TRahulSam1997/storybook-tailwind-next-typescript-v2
Any help would be much appreciated!
Upvotes: 10
Views: 8777
Reputation: 2510
Add the path to the stories folder in the tailwind.config.js file.
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
"./stories/**/*.{js,ts,jsx,tsx}", //instruct tailwind to read the stories folder
],
theme: {},
plugins: [],
}
Upvotes: 1
Reputation: 849
Update!
Simply doing this worked:
Import
import 'tailwindcss/tailwind.css';
into preview.js
Thanks to https://stackoverflow.com/a/68022201/12198222
Upvotes: 14