Update readme with small ThemeProvider example

This commit is contained in:
Melanie Seltzer 2020-05-04 14:32:02 -07:00 committed by GitHub
parent a26ff77afd
commit 0b5203b75c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -297,6 +297,33 @@ import { Meta, DocsContainer } from '@storybook/addon-docs/blocks';
Rest of your file...
```
This is especially useful if you are using `styled-components` and need to wrap your JSX with a `ThemeProvider` to have access to your theme:
```js
import { Meta, DocsContainer } from '@storybook/addon-docs/blocks';
import { ThemeProvider } from 'styled-components'
import { theme } from '../path/to/theme'
<Meta
title="Addons/Docs/container-override"
parameters={{
docs: {
container: ({ children, context }) => (
<DocsContainer context={context}>
<ThemeProvider theme={theme}>
{children}
</ThemeProvider>
</DocsContainer>
),
},
}}
/>
# Title
Rest of your file...
```
## More resources
- References: [README](../README.md) / [DocsPage](docspage.md) / [MDX](mdx.md) / [FAQ](faq.md) / [Recipes](recipes.md) / [Theming](theming.md) / [Props](props-tables.md)