Theme switcher
Four smooth ways to move between light and dark appearance.
npx shadcn@latest add @silicon-ui/theme-switchInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/theme-switchManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/theme-switch/theme-switch.tsx
- components/silicon-ui/theme-switch/theme-switch.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/button/button.tsx
- components/silicon-ui/button/button.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
theme* | Theme
| — |
onThemeChange* | (next: Theme, variant: ThemeSwitchVariant, trigger: HTMLElement) => void | — |
variant | ThemeSwitchVariant
| "reveal" |
label | string | — |
iconOnly | boolean | false |