Navigation
ThemeSwitch
System, Light or Dark. Sets data-theme on <html> and keeps the choice in this browser. Put THEME_SCRIPT in <head> so the choice applies before first paint.
import { ThemeSwitch, THEME_SCRIPT, useTheme } from "@percentsa/ui";Examples
import { THEME_SCRIPT } from "@percentsa/ui";
// app/root.tsx: no attribute = dark; the script applies the stored choice before first paint.
<html lang="en" data-theme="dark" suppressHydrationWarning>
<head>
<script dangerouslySetInnerHTML={{ __html: THEME_SCRIPT }} />
</head>Code
export function ThemeSwitchExample() {
return (
<Stack gap={4} className="w-full max-w-xl">
<ThemeSwitch />
<CodeBlock code={HEAD} filename="app/root.tsx" />
</Stack>
);
}