question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

storybook-addon-next does not work with tailwindcss 3.

See original GitHub issue

Describe the bug

  1. tailwindcss3 works well when using @storybook/addon-postcss (because tailwindcss3. needs postcss 8+. but storybook does not support postcss 8+.)
const path = require('path');

module.exports = {
  stories: [
    '../stories/**/*.stories.mdx',
    '../stories/**/*.stories.@(js|jsx|ts|tsx)',
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions',
    {
      name: '@storybook/addon-postcss',
      options: {
        postcssLoaderOptions: {
          implementation: require('postcss'),
        },
      },
    },
  ],
  framework: '@storybook/react',
  core: {
    builder: '@storybook/builder-webpack5',
  },
  webpackFinal: async (config) => {
    config.resolve.modules = [path.resolve(__dirname, '..'), 'node_modules'];

    return config;
  },
  staticDirs: ['../public'],
};

  1. but, storybook-addon-next does not work with postcss 8+. 😦. please help.
const path = require('path');

module.exports = {
  stories: [
    '../stories/**/*.stories.mdx',
    '../stories/**/*.stories.@(js|jsx|ts|tsx)',
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions',
    'storybook-addon-next',
    {
      name: '@storybook/addon-postcss',
      options: {
        postcssLoaderOptions: {
          implementation: require('postcss'),
        },
      },
    },
  ],
  framework: '@storybook/react',
  core: {
    builder: '@storybook/builder-webpack5',
  },
  webpackFinal: async (config) => {
    config.resolve.modules = [path.resolve(__dirname, '..'), 'node_modules'];

    return config;
  },
  staticDirs: ['../public'],
};

It occurs this error message. Error: PostCSS plugin tailwindcss requires PostCSS 8.

Your minimal, reproducible example

https://github.com/kyujonglee/storybook-nextjs-tailwindcss

Steps to reproduce

  1. npx create-next-app@lasest --typescript
  2. npx storybook init
  3. install @storybook/addon-postcss and tailwindcss postcss autoprefixer.

Expected behavior

storybook nextjs tailwindcss3

work together.

How often does this bug happen?

No response

Screenshots or Videos

No response

Platform

  • OS: macOS
  • browser: Chrome

storybook-addon-next version

v1.6.4

Additional context

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
RyanClementsHaxcommented, May 26, 2022

Oh boy do I have good news for you.

If you go to the examples portion of the readme for this addon, you will see that I have a tailwind css 3 example.

In short, you don’t need the storybook postcss addon 😃

Hope this helps

0reactions
RyanClementsHaxcommented, Dec 22, 2022

Yup! no problem!

Read more comments on GitHub >

github_iconTop Results From Across the Web

tailwind 3 doesn't work with storybook/webpack setup #6314
Basically just do yarn and yarn storybook and you'll see storybook loaded correctly. ... you'll see no tailwind is loaded inside storybook.
Read more >
Tailwind css classes not showing in Storybook build
When running build-storybook the components are rendered with the tailwind classes. Unfortunately, when I build storybook and run the create ...
Read more >
How to set up Storybook with Next.js and Tailwind CSS
This step-by-step tutorial is written with Storybook v6.4.9 & TypeScript, if you found the tutorial is not working after some minor update, ...
Read more >
storybook-addon-next - npm
A no config Storybook addon that makes Next.js features just work in Storybook. Latest version: 1.7.1, last published: 4 days ago.
Read more >
Storybook Addon PostCSS
The Storybook PostCSS addon can be used to run the PostCSS preprocessor against your stories in Storybook. Getting Started. Install this addon by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found