# Theme Spec

> A design language on one sheet, drawn from its tokens, from type and color to motion.

Page: https://uicontext.com/docs/components/theme-spec

Group: Foundations.

## When to use

A design language on one sheet, drawn from its tokens, from type and color to motion. Use [Themes](https://uicontext.com/docs/components/themes.md) instead when you want the tokens themselves, not a sheet that shows them.

## Usage

```ts
import { ThemeSignature } from "./ui/uicontext/components/ThemeSignature.ts"
import { ThemeSpec } from "./ui/uicontext/components/ThemeSpec.ts"
import { carbon } from "./ui/uicontext/components/themes.stylex.ts"
import { themeValues } from "./ui/uicontext/components/themeValues.ts"

export const CarbonSheet = <M>(h: Html.H<M>) =>
	ThemeSpec(h, {
		values: themeValues.carbon,
		mode: "dark",
		theme: carbon,
		signature: ThemeSignature(h, { key: "carbon", props: { signature: "query-panel" } }),
	})
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### A design language's spec sheet

The example the page opens with: Theme Spec in “A design language's spec sheet”.

```ts title="src/demo.ts" source="www/src/examples/theme-spec/demo.ts"
import type { Html } from "effect/ui/html"
import { ThemeSignature } from "./ui/uicontext/components/ThemeSignature.ts"
import { ThemeSpec } from "./ui/uicontext/components/ThemeSpec.ts"
import { sunburst } from "./ui/uicontext/components/themes.stylex.ts"
import { themeValues } from "./ui/uicontext/components/themeValues.ts"

// a whole design language on one sheet, drawn from its tokens, with its signature piece working
export const SunburstSheet = <M>(h: Html.H<M>) =>
	ThemeSpec(h, {
		values: themeValues.sunburst,
		mode: "light",
		theme: sunburst,
		signature: ThemeSignature(h, { key: "sunburst", props: { signature: themeValues.sunburst.signature } }),
	})
```

## API reference

### ThemeSpec (view function)

**Options**

| Name | Type | Description |
| --- | --- | --- |
| `values` (required) | `ThemeValues` | The theme's values, for the numbers the sheet prints |
| `mode` (required) | `"light" \| "dark"` | Which scheme to show: the sheet sets it, and prints that scheme's colors |
| `theme` | `Style[]` | The theme's StyleX themes; leave out when an ancestor sets the variables |
| `signature` | `View.Input` | The piece of UI that captures the language |
| `note` | `string` | A line under the summary, such as which template starts in it |
| `headingLevel` | `1 \| 2` | — |

### ThemeSignature (component)

**Props**

| Name | Type | Description |
| --- | --- | --- |
| `signature` (required) | `Signature` | — |

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/theme-spec
```

With npm: `npx shadcn@latest add checkfu/uicontext/theme-spec`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/theme-spec`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/theme-spec`.

It writes these files:

- `src/ui/uicontext/components/AppTheme.ts`
- `src/ui/uicontext/components/FormControls.ts`
- `src/ui/uicontext/components/IconStroke.ts`
- `src/ui/uicontext/components/InlineNotice.ts`
- `src/ui/uicontext/components/Kbd.ts`
- `src/ui/uicontext/components/SegmentedControl.ts`
- `src/ui/uicontext/components/ShowText.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/ThemeSignature.ts`
- `src/ui/uicontext/components/ThemeSpec.ts`
- `src/ui/uicontext/components/themeSpec.stylex.ts`
- `src/ui/uicontext/components/themeValues.ts`
- `src/ui/uicontext/components/themes.stylex.ts`
- `src/ui/uicontext/components/tokenValues.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`
- `src/ui/uicontext/components/touch.stylex.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/ThemeSpec.ts](https://github.com/checkfu/uicontext/blob/main/src/ThemeSpec.ts)
- [src/ThemeSignature.ts](https://github.com/checkfu/uicontext/blob/main/src/ThemeSignature.ts)
- [src/themeSpec.stylex.ts](https://github.com/checkfu/uicontext/blob/main/src/themeSpec.stylex.ts)

## Related

- [App Setup](https://uicontext.com/docs/components/app-setup.md) (`app-setup`): The build setup an app needs: Vite with StyleX, a base stylesheet and TypeScript settings.
- [App Bootstrap](https://uicontext.com/docs/components/app-bootstrap.md) (`app-bootstrap`): Starts an app from its routes, with sign-in in front and the shell and pages behind it.
- [Themes](https://uicontext.com/docs/components/themes.md) (`themes`): Color, type and spacing tokens, with light, dark and app themes you can nest.
- [App Frame](https://uicontext.com/docs/components/app-frame.md) (`app-frame`): The frame every app shares: a sidebar of links that becomes a drawer on a phone, a header row with breadcrumbs and actions, and an optional rail, tabs, side panel and status bar.
