Next.js using Tailwind with Storybook
Set up a Next.js project with the following command
if you have your preferred package manager, you can u...
For further actions, you may consider blocking this person and/or reporting abuse
This solution actually worked. Thanks for sharing this solution. However, I didn't change
postcss.config.mjs
topostcss.config.js
and the versions that I am using in my next.js project are"storybook": "^8.3.2"
and"tailwindcss": "^3.4.1"
. I have only importedglobal.css
inpreview.ts
.Thank you very much for this tutorial, I spent several hours researching how to configure storybook with nextjs and many tutorials on the internet mentioned that I had to modify many files and install more libraries, and in the end none of them worked, your tutorial is the simplest and the only functional one, thanks :)
I was there too, that's why I wrote this post. I also installed and uninstalled several packages. I'm really glad it helped :) Have a good day!
Has anyone had luck with passing styles through storybook that aren't compiled in a component already? Like if I pass bg-pink-500 - I'm not using this anywhere in my project so it doesn't work. But if I pass bg-yellow-500 it works since I'm using it elsewhere. Any ideas?
Thank you!!
You helped me solve an issue in my react-typescript application built using Vite. The issue I was facing was my tailwind classes are not applied to my storybook components.
The missing piece was the following line in .storybook/preview.ts file,
After searching through lot of articles finally I landed on your article and solved the issue. In order for tailwind classes to work we need to import the main CSS file with tailwind directives into preview.ts file in storybook folder.
Once again Thanks!
i had an error
node-modules/acron and acron--jsx not found
So i did :
npm i -D @storybook/addon-styling
npm i acorn acorn-jsx
import the global.css file of your tailwind config in .storybook/preview.js => import "../assets/styles/globals.css"
Restart storybook
and it worked
Thanks! U r smarter than chatgpt, copilot, bard and a few friends
Thank you. really helpful.
Another question, unrelated. This EBUSY error happens essentially anytime I change anything. Is this just the norm? Any good solutions using storybook 7 with NextJS?
Im using the exact versions that dont work, if I change the storybook version might work ? which is the best version ?
The new solution I updated doesn't work for you? installing postcss, autoprefixer and creating the postcss configuration file
not working with:
"storybook": "^8.0.8",
"tailwindcss": "^3.4.1",
Thanks for sharing the issue. I have updated the post!
This solved it for me. Thank you!
Glad to hear that it helped you!
Thank you