Skip to content

Files

Latest commit

Dec 26, 2019
9c5005e · Dec 26, 2019

History

History
This branch is 44208 commits behind storybookjs/storybook:next.

cssresources

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Oct 30, 2018
Oct 14, 2019
Nov 27, 2019
Dec 26, 2019
Oct 29, 2018
Jan 27, 2019

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 />
);