Theme Toggle

Light and dark mode toggle with a drawn sun that turns into a crescent moon. Comes as an icon, pill or switch, and passes on where you tapped so your app can flood the new theme out from the button.

Preview

Installation

npx @lumioui/cli add theme-toggle

Usage

import { ThemeToggle } from "@/components/ui/theme-toggle/theme-toggle";
<ThemeToggle />

Examples

Icon

The reader is the hero.

Pill

The labeled toggle in a project tool's account menu, between the settings rows and sign out.

Switch

The dark-mode switch in a Display settings group, next to the rows it lives with.

API reference

Prop Type Default
variant ThemeToggleVariant

Visual style. Default "icon".

"icon"
scheme ThemeScheme

Controlled scheme. Default: the ThemeProvider's scheme.

—
onSchemeChange
(next: ThemeScheme … (next: ThemeScheme, event: GestureResponderEvent) => void

Called with the next scheme and the press — use it to flood the new scheme out of the toggle. When set, the toggle does not change the ThemeProvider override itself.

—
accessibilityLabel string

Accessible label. Default announces the action — "Switch to light theme" / "Switch to dark theme" based on current state.

—
className string —