Skip to content

Theme Switch

Free

A control that switches a site between light and dark: an icon button, a switch, or a Light, Dark, and System choice, with an animated page change.

  • Base UI
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Wrap the app in the next-themes ThemeProvider, then place the control.

theme-choice.tsx

ThemeSwitch

PropTypeDefaultDescription
control"segmented""switch""toggle""toggle"toggle: one icon button (Base UI Toggle). switch: a track and a thumb (Base UI Switch). segmented: light, dark, and system (Base UI Toggle Group).
transition"blinds""blur""circle""diagonal""fade""none""wipe""circle"The page change. Default circle, from the click point.
size"default""lg""sm""default"Toggle 28/32/36, switch 36/44/52 wide, segmented items 24/28/32.
variant"default""outline""default"The toggle look: no rest fill, or the field surface with an edge.
showLabelsbooleanfalseSegmented only: the item names show next to the icons.
value"dark""light""system"—The theme, for a controlled control or another theme store. Default: next-themes theme.
onValueChange—Called with the new theme inside the page change. Without value, next-themes gets it too. Update the page synchronously here (React state, a store with no async middleware): the page change takes its picture of the new page when this call returns.
disabledboolean—
labels—Screen reader names, and the segmented labels.
classNamestring—
idstring—
  • Use control="toggle" (default) in a header, switch in a settings row, and segmented when users can also follow the system.
  • Pick the page change with transition: circle, wipe, diagonal, blinds, fade, blur, or none.
  • Wrap the app in the next-themes ThemeProvider with attribute="class".
  • For an on and off setting that is not the theme, use a Switch.
  • For a choice of other values, use a Segmented Control.
SpaceChanges the theme, or picks the focused theme (segmented).
EnterChanges the theme, or picks the focused theme (segmented).
Arrow keysMove the focus between light, dark, and system (segmented).
Page change
theme · 450ms · ease-panel · the new theme reveals through a View Transition, in the shape that `transition` picks

Built with

Installs with Theme Switch

Components
Switch,Toggle
  1. AddedTheme Switch, with Switch, Toggle.
Open the release