import * as React from 'react'; /** * Puts the kit's dark mode on the document, which is the only way it turns on. * * `globals.css` declares `@custom-variant dark (&:where(.dark, .dark *))`, so * `dark:` utilities key off a **class on an ancestor**, not off * `prefers-color-scheme`. Nothing in `dist/` toggles it: a consuming app owns * that switch, and this is the two lines such an app writes. * * Shared because the kit has two doc surfaces that each need it — the showcase's * `?theme=` parameter and Storybook's theme toolbar — and a copy in each meant * the mechanism was documented twice and could be corrected once. It lives on * the showcase side of the line on purpose: `.storybook/` is what a scaffold can * be generated without, the showcase always ships. */ export function useThemeClass(theme: 'light' | 'dark' | string) { React.useEffect(() => { document.documentElement.classList.toggle('dark', theme === 'dark'); }, [theme]); }