manager to persist a users color mode preference in
omit if you don't render server-side
for SSR: choose cookieStorageManager
Chakra UI + Storybook
Use the official Storybook Addon for Chakra UI to configure Storybook to
automatically wrap your stories with the <ChakraProvider />
and add a color
mode toggle.
Installation#
yarn add -D @chakra-ui/storybook-addonyarn add @chakra-ui/icons
npm i -D @chakra-ui/storybook-addonnpm i @chakra-ui/icons
Usage#
Add the addon to your configuration in .storybook/main.js
:
module.exports = {addons: ['@chakra-ui/storybook-addon'],}
You can specify global parameters for the addon in .storybook/preview.js
.
These options are the same as the props to ChakraProvider
(without
children
).
// .storybook/preview.jsconst theme = require('../path/to/your/theme')export const parameters = {chakra: {theme,},}
colorModeManager
colorModeManager
StorageManager
localStorageManager
cssVarsRoot
cssVarsRoot
string
environment
environment
The environment (window
and document
) to be used by
all components and hooks.
By default, we smartly determine the ownerDocument and defaultView
based on where ChakraProvider
is rendered.
Environment
portalZIndex
portalZIndex
Common z-index to use for Portal
number
undefined
resetCSS
resetCSS
If true
, CSSReset
component will be mounted to help
you reset browser styles
boolean
true
theme
theme
a theme. if omitted, uses the default theme provided by chakra
Dict<any>