Theme switch
A React component in Beamline's Actions category.
The light/dark control: the page changes in one of four transitions starting from the button (reveal, eclipse, split, rise), and the icon turns between sun and moon.
Use it for
- A visible appearance control in settings or an app header.
Not for
- Products that ship dark only: keep the preference in settings.
Anatomy
- Button
- sun / moon icon
- label
Variants
- variant: reveal, eclipse, split, rise
- buttonVariant: secondary, ghost, outline
States
- dark
- light
- transitioning
Keyboard
- Enter / Space switches
Motion
The new theme is revealed by clipping only the new page snapshot (no stylesheet is added): reveal grows a circle from the button, eclipse closes an even-odd hole into it, split opens from the middle, rise from the bottom; 540 ms (1.5 × considered) on the in-out curve. The icon turns between sun and moon over 280 ms. Reduced motion or no View Transitions: instant swap.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
theme | "light" | "dark" | — | |
onThemeChange | (next, variant, trigger) => void | — | |
variant | ThemeSwitchVariant | "reveal" | |
label | string | "Theme" | |
iconOnly | boolean | — | |
transitionTheme(apply, variant, from) | function | — | the transition alone, for your own control |
style / ref | CSSProperties / native Ref | — | native HTMLButtonElement |
classNames | ThemeSwitchClassNames | — |
Dependencies
lucide-react, motion
Import
import { ThemeSwitch } from "@/components/theme-switch/theme-switch";
Get it
Theme switch is part of Beamline: 190 React components and screens your coding agent (Claude Code, Codex, Cursor or any MCP client) installs into your app through Beamline's MCP server, as a ready-built package or as plain React source you can change. $49 one payment (regular $200), no subscription, a year of updates, one licence for your whole team. Get Beamline · Connect your agent
More in Actions
- Button: The action control: five weights and a brand fill, a buy/sell tone, sm/md/lg and a 44 px touch size, icon-only, a loading state that keeps its size and…
- Confirm morph: A destructive action that asks in place: the button morphs into its question, then into working, then into the result with Undo or Retry, without a dialog.
- Copy button: Copies a value and confirms in place: the icon becomes a check and the label says Copied; a refused copy says so instead of pretending.
- Hold to confirm: Confirms a costly action by holding instead of clicking: a fill sweeps across while held and drains if let go early; pointer, touch, Space and Enter all…
- Split button: One obvious action joined to a menu of close alternatives; both halves are real buttons and the menu uses the shared menu rows.
- Swipe actions: Row actions behind a swipe on touch screens, mirrored in a menu at the row's end for pointer and keyboard; a full swipe runs the edge action.