Theme Switcher
Component that allows users to switch between light and dark themes.
Best Practices
- Use Theme Switcher for the canonical Light / System / Dark control. Place it once per app, in the footer or settings, not duplicated across pages.
- Pass
smallfor dense chrome (footers, dropdowns); use the default size on a settings page where there’s room for the labels to breathe. - Theme Switcher reads from and writes to
next-themes, so wrap the app inGeistProvideronce at the root and don’t mirror its state into local React state. - The control auto-disables when
forcedThemeis set on the provider; settingdisabledmanually is for read-only previews of the control itself. - Don’t rebuild a theme picker with Switch or three icon buttons. Theme Switcher already handles the icons, the
aria-labelper option, and System detection. - The component composes its own labels from the theme keys (
light,system,dark); leave them alone so they stay translatable throughnext-themes.
Was this helpful?