More Premium Hugo Themes Premium React Themes

Storybook Addon Styled Component Theme

storybook addon

Storybook Addon Styled Component Theme

storybook addon

Author Avatar Theme by echoulen
Github Stars Github Stars: 192
Last Commit Last Commit: Feb 25, 2022 -
First Commit Created: Jan 15, 2024 -
Storybook Addon Styled Component Theme screenshot

Overview:

The styled-components-addon is an npm addon that enables Storybook to showcase components with multiple different styled-component themes. It supports Storybook versions 4, 5, 6, and newer.

Features:

  • Multiple styled-component themes support
  • Compatible with Storybook versions 4, 5, 6, and newer

Installation:

To install the styled-components-addon, follow these steps:

Storybook v6:

  1. Add the following code snippet to .storybook/preview.js:

    import { addDecorator } from '@storybook/react';
    import { withThemesProvider } from 'styled-components-addon';
    
    // Add your theme objects here
    const themes = [...];
    
    addDecorator(withThemesProvider(themes));
    
  2. Add the following code snippet to .storybook/main.js:

    module.exports = {
      addons: [
        {
          name: 'styled-components-addon',
          options: {
            themeNameSelector: '.theme-selector',
          },
        },
      ],
    };
    

Storybook v5 and v4:

  1. Add the following code snippet to .storybook/addons.js:

    import 'styled-components-addon/register';
    
  2. Add the following code snippet to .storybook/preview.js:

    import { addDecorator } from '@storybook/react';
    import { withThemesProvider } from 'styled-components-addon';
    
    // Add your theme objects here
    const themes = [...];
    
    addDecorator(withThemesProvider(themes));
    

Summary:

The styled-components-addon is a helpful npm package that integrates styled-components themes with Storybook. It provides support for showcasing components with multiple different themes and is compatible with Storybook versions 4, 5, 6, and newer. The installation process involves adding code snippets to the Storybook configuration files.