# Theme button

A shadcn/ui font and colour theme picker for AI site builders and editors: the toolbar pill morphs into the menu, then folds back.

> For the complete documentation index, see [llms.txt](/llms.txt). Markdown variants are available for the docs, pricing and about pages: append `.md` to the URL or send an `Accept: text/markdown` header (the home page answers the header too). An agent skill is available at [/.well-known/agent-skills/site-skill.md](/.well-known/agent-skills/site-skill.md).

## At a glance

- **Good for:** Theme and font pickers in AI site builders; Appearance controls in editors and design tools; Brand kit switchers in no-code builders; Floating toolbars in canvas and slide apps
- **Category:** Click & press · **Type:** Menus, Buttons · **Style:** Motion, Minimal, Dark mode
- **See it:** [Live preview](https://www.craftui.space/docs/interactions/theme-button)

## Install

```bash
pnpm dlx shadcn@latest add https://www.craftui.space/r/theme-button.json
```

Free to install.

## Usage

```tsx
import ThemeButton from "@/components/interactions/theme-button/theme-button";

export default function Page() {
  return <ThemeButton />;
}
```

With no props it renders with demo content; pass your own through the props below.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `themes` | `ThemeOption[] \| (() => ThemeOption[])` | — | Theme list, or a function returning it. Falls back to the built-in set. |
| `fonts` | `FontOption[] \| (() => FontOption[])` | — | Font list, or a function returning it. Falls back to the built-in set. |
| `defaultThemeId` | `string` | — | Uncontrolled starting theme (by id). |
| `defaultFontId` | `string` | — | Uncontrolled starting font (by id). |
| `themeId` | `string` | — | Controlled theme (by id). When set, the theme is controlled. |
| `fontId` | `string` | — | Controlled font (by id). When set, the font is controlled. |
| `onThemeChange` | `(theme: ThemeOption) => void` | — | Called with the full option after someone picks a theme. Not called by `demo`. |
| `onFontChange` | `(font: FontOption) => void` | — | Called with the full option after someone picks a font. Not called by `demo`. |
| `onOpenChange` | `(mode: Mode \| null) => void` | — | Called with "font" or "theme" when a menu opens, and null when it closes. Not called by `demo`. |
| `processLabel` | `string` | — | The word next to the pulse. |
| `showProcess` | `boolean` | — | Shows the pulse and its word. Set false to hide that segment. |
| `demo` | `boolean` | — | Opens the theme menu, picks the next theme, then does the same for fonts, on a loop while in view and untouched, with no Tab stops. For previews and gallery cards. |
| `className` | `string` | — | Extra classes for the pill and the menu (the shell). |

### `ThemeOption`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Stable id, used for selection. |
| `label` (required) | `string` | The name shown in the bar and the menu. |
| `dots` (required) | `string[]` | 1–3 colours. The first is the bar's swatch; all of them render as a stacked row in the menu. |

### `FontOption`

| Field | Type | Description |
| --- | --- | --- |
| `id` (required) | `string` | Stable id, used for selection. |
| `label` (required) | `string` | The name shown in the bar and the menu, set in the font itself. |
| `stack` (required) | `string` | A CSS font-family stack, used to preview the face and as the value. Load the font in your app for the preview to show it. |

## Files

The install adds:

- `components/interactions/theme-button/theme-button.tsx`
- `components/interactions/theme-button/DESIGN.md`

npm dependencies (installed for you): `motion`.