@storybook/addon-themes
TypeScript icon, indicating that this package has built-in type declarations

8.0.9 • Public • Published

@storybook/addon-themes

Storybook Addon Themes can be used which between multiple themes for components inside the preview in Storybook.

React Storybook Screenshot

Usage

Requires Storybook 7.0 or later. If you need to add it to your Storybook, you can run:

npm i -D @storybook/addon-themes

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

export default {
  addons: ['@storybook/addon-themes'],
};

👇 Tool specific configuration

For tool-specific setup, check out the recipes below

Don't see your favorite tool listed? Don't worry! That doesn't mean this addon isn't for you. Check out the "Writing a custom decorator" section of the api reference.

❗️ Overriding theme

If you want to override your theme for a particular component or story, you can use the themes.themeOverride parameter.

import React from 'react';
import { Button } from './Button';

export default {
  title: 'Example/Button',
  component: Button,
  parameters: {
    themes: {
      themeOverride: 'light', // component level override
    },
  },
};

export const Primary = {
  args: {
    primary: true,
    label: 'Button',
  },
};

export const PrimaryDark = {
  args: {
    primary: true,
    label: 'Button',
  },
  parameters: {
    themes: {
      themeOverride: 'dark', // Story level override
    },
  },
};

Package Sidebar

Install

npm i @storybook/addon-themes

Weekly Downloads

259,220

Version

8.0.9

License

MIT

Unpacked Size

18.4 kB

Total Files

10

Last publish

Collaborators

  • jreinhold
  • thafryer
  • shaunlloyd
  • kylegach
  • ndelangen
  • shilman
  • alexandrebodin
  • hypnosphi
  • danielduan
  • igor-dv
  • pksunkara
  • tmeasday
  • gongreg
  • domyen
  • usulpro
  • kylesuss
  • ghengeveld
  • pago
  • dandean
  • mrmckeb
  • dannyhw
  • winkervsbecks
  • amalik2
  • phated
  • yannbf
  • dylanpiercey
  • darleendenno