---
title: "Theme Switch"
description: "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."
url: https://gelatinui.com/components/theme-switch
markdown_url: https://gelatinui.com/components/theme-switch.md
access: free
install: "npx shadcn@latest add @gelatin-ui/theme-switch"
registry_item: https://gelatinui.com/r/theme-switch.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Theme Switch

> 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.

Page: https://gelatinui.com/components/theme-switch

## When to use it

Best for: A light and dark control in a site header or a settings page.

- 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"`.

## When not to use it

- For an on and off setting that is not the theme, use a [Switch](https://gelatinui.com/components/switch.md).
- For a choice of other values, use a [Segmented Control](https://gelatinui.com/components/segmented-control.md).

## Notes for agents

- It reads and sets the theme through next-themes `useTheme`; it holds no theme state of its own.
- Before hydration it shows a still placeholder, so the server and the browser match.
- A click starts the page change at the pointer; Enter or Space starts it at the middle of the control.
- Browsers with no View Transitions change the theme at once.

## Anatomy

```text
ThemeSwitch
```

## API reference

### ThemeSwitch

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `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. |
| `showLabels` | `boolean` | false | Segmented only: the item names show next to the icons. |
| `value` | `ThemeValue` |  | The theme, for a controlled control or another theme store. Default: next-themes `theme`. |
| `onValueChange` | `function` |  | 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. |
| `disabled` | `boolean` |  |  |
| `labels` | `Partial` |  | Screen reader names, and the segmented labels. |
| `className` | `string` |  |  |
| `id` | `string` |  |  |

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| ThemeSwitch | `theme-switch` |  |  |  |

## Usage

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

```tsx title="theme-choice.tsx"
import { ThemeSwitch } from "@/components/controls/theme-switch";

export function ThemeChoice() {
  return <ThemeSwitch control="segmented" showLabels />;
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/theme-switch
```

It adds 27 registry items: 24 files, 3820 lines, and the npm packages `@base-ui/react`, `@mantine/hooks`, `@phosphor-icons/react`, `clsx`, `motion`, `next-themes`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Switch](https://gelatinui.com/components/switch.md)
- [Toggle](https://gelatinui.com/components/toggle.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Switch](https://gelatinui.com/components/switch.md)
- [Toggle](https://gelatinui.com/components/toggle.md)
- [Segmented Control](https://gelatinui.com/components/segmented-control.md)
- [Burger Menu Icon](https://gelatinui.com/components/burger-menu-icon.md)

## Keyboard

| Keys | Action |
| --- | --- |
| Space | Changes the theme, or picks the focused theme (segmented). |
| Enter | Changes the theme, or picks the focused theme (segmented). |
| Arrow keys | Move the focus between light, dark, and system (segmented). |

## Motion

| Part | Motion |
| --- | --- |
| Page change | theme · 450ms · ease-panel · the new theme reveals through a View Transition, in the shape that `transition` picks |
