Skip to content

integrating theme-ui with storybook in a gatsby project #354

@dennyabrain

Description

@dennyabrain

Hi,

I have a gatsby project where I have integrated theme-ui. Now i am trying to incorporate storybook in the project so I can develop a component library for my project.

I want my components to rely on theme-ui and the sx prop for styling but when i write stories, they render in the storybook UI without the style applied.

I am a bit lost on how to debug this.

this is what the relevant portion of my .storybook/config.js file looks like

import { configure, addDecorator } from '@storybook/react';
import React from 'react'
import { ThemeProvider } from 'theme-ui'
import theme from '../src/gatsby-plugin-theme-ui/index'

// automatically import all files ending in *.stories.js
const req = require.context('../stories', true, /\.stories\.js$/);
function loadStories() {
  req.keys().forEach(filename => req(filename));
}

addDecorator((story) => (
  <ThemeProvider theme={theme}>
    {story()}
  </ThemeProvider>
))

configure(loadStories, module);

Any help on where to start debugging this are appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions