@codinggorilla/storybook-theme-changer
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Storybook Theme Changer

A Storybook react addon to change the theme used by an Emotion theme provider.

Usage

// main.ts
import '@codinggorilla/storybook-theme-changer/dist/register';

export default {
    addons: ['@codinggorilla/storybook-theme-changer/dist']
}
// preview.tsx
import { Theme } from '@emotion/react';
import { Story, StoryContext } from '@storybook/react';
import { WithThemesProvider } from '@codinggorilla/storybook-theme-changer';

// Themes
import standardTheme from '../themes/standard';
import darkTheme from '../themes/dark';

function ThemeDecorator(Story: Story, Context: StoryContext) {
    const themes: Theme[] = [
        standardTheme,
        darkTheme
    ]

    return WithThemesProvider(themes, Story, Context);
}

export const decorators = [ThemeDecorator];

Package Sidebar

Install

npm i @codinggorilla/storybook-theme-changer

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

9.08 kB

Total Files

17

Last publish

Collaborators

  • coding-gorilla