-
-
Save webdesignberlin/8289848f69b3d860d87e93e2ba31df7b to your computer and use it in GitHub Desktop.
Storybook docs page tailwind dark mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@tailwind base; | |
@tailwind components; | |
@tailwind utilities; | |
@layer base { | |
* { | |
@apply border-border; | |
} | |
body, | |
.docs-story { | |
@apply bg-background text-foreground; | |
font-feature-settings: | |
'rlig' 1, | |
'calt' 1; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react'; | |
import { addons, types, useGlobals } from '@storybook/manager-api'; | |
const ExampleToolbar = () => { | |
const [globals] = useGlobals(); | |
useEffect(() => { | |
const elements = document.querySelectorAll('.docs-story'); | |
elements.forEach((element) => { | |
element.classList.add(globals['theme'] as string); | |
}); | |
}, [globals]); | |
return null; | |
}; | |
addons.register('docs-theme', () => { | |
addons.add('docs-theme-addon', { | |
title: 'Addon to change docs story theme', | |
type: types.TOOL, | |
match: ({ viewMode }) => !!viewMode?.match(/^(story|docs)$/), | |
render: ExampleToolbar, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment