@gfpacheco/storybook-tailwind-dark-mode

1.0.25 • Public • Published

storybook-tailwind-dark-mode

Example

Installation

Install the following npm module:

npm i --save-dev @gfpacheco/storybook-tailwind-dark-mode

or with yarn:

yarn add -D @gfpacheco/storybook-tailwind-dark-mode

Then, add following content to .storybook/main.js

module.exports = {
  addons: ['@gfpacheco/storybook-tailwind-dark-mode'],
};

Make sure tailwind is configured to use the darkmode class in the tailwind.config.js

module.exports = {
  darkMode: 'class',
  // ...
} 

Set Dark Mode as default

To set dark mode as default, Add the following lines of code to your preview.js file

const preview = {
  globalTypes: {
    darkMode: {
      defaultValue: true, // Enable dark mode by default on all stories
    },
    // Optional (Default: 'dark')
    className: {
      defaultValue: 'custom-classname', // Set your custom dark mode class name
    },
  },
};

Package Sidebar

Install

npm i @gfpacheco/storybook-tailwind-dark-mode

Weekly Downloads

0

Version

1.0.25

License

MIT

Unpacked Size

16.2 kB

Total Files

12

Last publish

Collaborators

  • gfpacheco