Michael Shilman d6d745006f v5.3.7
2020-01-20 14:51:39 +08:00
..
2018-10-29 18:26:55 -07:00
2019-10-15 00:53:33 +02:00
2020-01-20 14:51:39 +08:00
2019-11-27 16:31:36 +01:00
2018-10-29 15:03:59 -07:00

Storybook Addon Cssresources

Storybook Addon Cssresources to switch between css resources at runtime for your story Storybook.

Framework Support

Storybook Addon Cssresources Demo

Installation

yarn add -D @storybook/addon-cssresources

Configuration

Then create a file called main.js in your storybook config.

Add following content to it:

module.exports = {
  addons: ['@storybook/addon-cssresources/register']
}

Usage

You need add the all the css resources at compile time using the withCssResources decorator. They can be added globally or per story. You can then choose which ones to load from the cssresources addon UI:

import { withCssResources } from '@storybook/addon-cssresources';

export default {
  title: 'CssResources',
  parameters: {
    cssresources: [{
        id: `bluetheme`,
        code: `<style>body { background-color: lightblue; }</style>`,
        picked: false,
      },
    ],
  },
  decorators: [withCssResources],
};

export const defaultView = () => (
  <div />
);