When you click the dark mode toggle at the top right of a vitro app all the stories on the page gets re-rendered with an additional prop isDark
set to true
When the dark mode is enabled all your stories components and wrappers will receive a prop isDark
set to true
This way you can handle the color mode state yourself, adding a react context in the wrapper for example
1import { ColorModeProvider } from '@chakra-ui/system'23export default {4title: 'Example',5wrapper: ({ isDark, isFullScreen, children }) => (6<ColorModeProvider value={isDark ? 'dark' : 'light'}>7<ThemeProvider>{children}</ThemeProvider>8</ColorModeProvider>9),10}1112export const MyExperiment = ({ isDark }) => (13<div>dark mode is {isDark ? 'enabled' : 'disabled'}</div>14)
You can use a global wrapper to add dark mode state to all your stories
remember to pass the name of the file that exports the wrapper in the config wrapper
option
1import { ColorModeProvider } from '@chakra-ui/system/src'23import React from 'react'45export const Wrapper = ({ isDark, children }) => (6<ColorModeProvider value={isDark ? 'dark' : 'light'}>7<ThemeProvider>{children}</ThemeProvider>8</ColorModeProvider>9)1011export default Wrapper