# Theme Switch

> Switches the page theme: the sun pulls in its rays and is eclipsed into a moon while the new theme spreads out from the button.

## Spec sheet

| | |
| --- | --- |
| Access | Free: no account, free for commercial use |
| Shelf | Components › Buttons |
| Live preview | https://uibrik.com/components/theme-switch |
| Writes | 1 file into `components/uibrik/theme-switch/` |
| Packages | `motion` (the CLI installs them) |
| Needs | React 19, Tailwind CSS v4, a project set up with `npx shadcn@latest init` |
| Theme | Reads the shadcn tokens and follows class-based dark mode ([theming](https://uibrik.com/docs/theming.md)) |
| Updated | Nov 9, 2026 |

## Add it

```bash
npx shadcn@latest add https://uibrik.com/r/theme-switch.json
```

With the `@uibrik` namespace in `components.json` ([setup](https://uibrik.com/docs/installation.md)): `npx shadcn@latest add @uibrik/theme-switch`.

Can't run commands? https://uibrik.com/components/theme-switch/prompt.txt has every file verbatim, with the setup steps, ready for an assistant to write.

## Render it

Renders as is; every value shown is the default, so delete any line you don't need.

```tsx
import { ThemeSwitch } from "@/components/uibrik/theme-switch/theme-switch";

<ThemeSwitch
  reveal="circle"
  revealDuration={0.5}
  easing="auto"
  size={40}
  radius={12}
  storageKey="theme"
  onChange={(theme) => {}}
  // theme="light"
  // setTheme={(theme, origin) => {}}
/>
```

## Tune it

The same props as the Customize panel on https://uibrik.com/components/theme-switch.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `reveal` | `"circle" \| "expand" \| "split" \| "wipe" \| "diagonal" \| "blinds" \| "blur" \| "zoom" \| "none"` | `"circle"` | How the new theme takes over the page. |
| `revealDuration` | `number` | `0.5` | How long the reveal takes. |
| `easing` | `"auto" \| "out" \| "in-out" \| "linear"` | `"auto"` | Auto uses each mode's own curve: ease-out for reveals from a point, ease-in-out for sweeps. |
| `wipeFrom` | `"left" \| "right" \| "top" \| "bottom"` | `"left"` | Which edge of the page the wipe starts from. |
| `corner` | `"top-left" \| "top-right" \| "bottom-left" \| "bottom-right"` | `"top-left"` | Which corner the diagonal sweeps in from. |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Split: a band opening up and down, or sideways. Blinds: rows or columns. |
| `slats` | `number` | `8` | How many slats the blinds have. |
| `cascade` | `number` | `0` | 0 opens every slat together; higher opens them one after another. |
| `blurAmount` | `number` | `8` | How far the pages blur. |
| `depth` | `number` | `0.04` | How far the pages scale (0.04 is 4%). |
| `size` | `number` | `40` | Width and height. |
| `radius` | `number` | `12` | Corner radius. |

## Wire it

The props the Customize panel doesn't show: ranges, data, content and callbacks.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `theme` | `"light" \| "dark"` |  | Controlled theme. Leave unset and the button follows the page's own theme (the dark class on <html>). |
| `onChange` | `(theme: "light" \| "dark") => void` |  | Called with the theme being switched to. |
| `setTheme` | `(theme: "light" \| "dark", origin: { x: number; y: number }) => void` |  | Applies the theme in place of the built-in page switch, e.g. a theme provider's setter. Gets the button's centre. |
| `storageKey` | `string` | `"theme"` | localStorage key the choice is saved under. |
| `className` | `string` |  | Classes for the button. |

## Where it fits

- **Light and dark toggles**: The sun eclipsing into a moon while the new theme spreads from the button makes switching delightful. Pairs with [Tactile Toggle](https://uibrik.com/components/tactile-toggle.md).
- **Site headers**: A compact icon button fits any navbar. Pairs with [Floating Navbar](https://uibrik.com/components/floating-navbar.md) (Pro).
- **Docs and blogs**: Readers who switch themes often get a clear, quick toggle.

## Same shelf: Buttons

- [Announcement Pill](https://uibrik.com/components/announcement-pill.md): A small New pill for above a hero heading, with a band of light along its border and an arrow that grows on hover.
- [Balloon Button](https://uibrik.com/components/balloon-button.md): An inflated, half-balloon button drawn with a WebGL shader, with folds along its seam and a springy dent when pressed.
- [Bookmark Button](https://uibrik.com/components/bookmark-button.md): A save button whose bookmark fills from the top like a dropped ribbon while the label rolls to Saved.
- [Chain Copy](https://uibrik.com/components/chain-copy.md): A copy-link button whose chain icon snaps apart when pressed, flings two chips from the break, then swings back together and relinks as the label rolls to Copied.
- [Copy Button](https://uibrik.com/components/copy-button.md): A copy button whose two sheets slide together into a check while the label rolls to Copied.
- [Expand Button](https://uibrik.com/components/expand-button.md): An icon-only button that springs open to reveal its label on hover or keyboard focus.

## Ground rules

- Only the props above exist. To change anything else, edit the installed file.
- Keep the files in `components/uibrik/theme-switch/` so the import paths keep resolving.
- The playbook for working with the whole library: https://uibrik.com/llms.txt
