@flightstats/storybook-stylesheet-toggle

0.1.4 • Public • Published

Storybook Stylesheet Toggle

A simple addon for Storybook that allows you to define a set of stylesheets that can be toggled between. This may be useful if your project has multiple themes, or if you want to stress test your components in different styling environments.

Getting started

yarn add -D storybook-stylesheet-toggle

Install the addon in .storybook/main.js:

module.exports = {
  addons: ["storybook-stylesheet-toggle"],
};

Add the following configuration to .storybook/preview.js:

import { addParameters } from '@storybook/react';

addParameters({
  stylesheetToggle: {
    stylesheets: [
      {
        id: 'first',
        title: 'First stylesheet',
        url: 'path/to/first-sheet.css',
      },
      {
        id: 'second',
        title: 'Second stylesheet',
        url: 'path/to/second-sheet.css',
      },
    ],
  },
});

Ensure the path to your stylesheets is being served by Storybook (with the -s ./path parameter.)

Boot Storybook, and you should now see a paintbrush menu, allowing you to toggle between the stylesheets you've configured. The first stylesheet will be applied by default.

Package Sidebar

Install

npm i @flightstats/storybook-stylesheet-toggle

Weekly Downloads

1

Version

0.1.4

License

MIT

Unpacked Size

16.9 kB

Total Files

12

Last publish

Collaborators

  • flightstats