Skip to content
This repository has been archived by the owner on Apr 28, 2024. It is now read-only.

TheCodingGorilla/storybook-theme-changer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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];