Skip to content

Tailwind - Storybook - react - typescript. How to add tailwind to storybook #13538

Answered by yannbf
nivekithan asked this question in Help
Discussion options

You must be logged in to vote

Hey @nivekithan I believe I answered you on Stackoveflow but I'll put the answer here so it can help others as well!

You're almost there.

The missing piece of your config is to add a webpack configuration to apply tailwind to postcss-loader:

// .storybook/main.js
const path = require('path')

module.exports = {
  stories: [
    '../src/**/*.stories.mdx', 
    '../src/**/*.stories.@(js|jsx|ts|tsx)'
  ],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/preset-create-react-app',
  ],
  webpackFinal: async (config) => {
    config.module.rules.push({
      test: /\.css$/,
      use: [
        {
          loader: 'postcss-loader',
          options: {

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by nivekithan
Comment options

You must be logged in to vote
1 reply
@lirbank
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants