Installation
npx shadcn@latest add @iconiq/theme-toggleProps
ThemeToggle
Client-only pill switch that toggles light and dark mode by adding or removing the `dark` class on `document.documentElement`, with sun and moon icons inside a sliding knob.
size"sm" | "md" | "lg"Default md
classNamestringOn mount, the control reads `prefers-color-scheme: dark` and syncs both local state and the document `dark` class.
Before hydration completes, a neutral placeholder button is rendered to avoid layout shift while keeping an accessible name.
The toggle manages theme locally via the `dark` class; pair it with your own CSS variables or Tailwind dark mode setup.
Install path is `components/ui/theme-toggle.tsx` with the `ThemeToggle` export.
Registry bundle
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: @base-ui/react/toggle, lucide-react.
This page documents the Base UI install only. Theme Toggle uses the Base UI Toggle primitive for pressed state.
The generated registry file is /r/theme-toggle.json.