# zidane-ui/theme

Import: `import { … } from 'zidane-ui/theme'`. Source: [ui/src/theme/index.ts](https://github.com/Tahul/zidane/blob/main/ui/src/theme/index.ts).

## Functions

### `legacyThemePatch`

Function.

The change a first run's appearance takes from `legacyThemeId`, or `null` for none: an unknown id (a fallback is
never pinned) or the default theme leave the defaults alone.

```ts
function legacyThemePatch(
  legacyThemeId: string | undefined,
  extraThemes?: readonly Theme[],
): LegacyThemePatch | null
```

**Parameters**

- `legacyThemeId` (`string | undefined`): The theme id the settings name.
- `extraThemes?` (`readonly Theme[]`, default `[]`): Themes beyond the built-in ones (extensions').

**Returns** `LegacyThemePatch | null`

Source: [ui/src/theme/legacy-theme.ts:20](https://github.com/Tahul/zidane/blob/main/ui/src/theme/legacy-theme.ts#L20)

### `paletteOf`

Function.

Derives the palette of `theme`, its accent (and focus ring) replaced by `accentOverride` when set.

```ts
function paletteOf(theme: Theme, accentOverride?: string | null): ResolvedPalette
```

**Parameters**

- `theme` (`Theme`): The active theme.
- `accentOverride?` (`string | null`, default `null`): The user's accent (`#rrggbb`), or `null` for the theme's own.

**Returns** `ResolvedPalette`

Source: [ui/src/theme/palette-of.ts:17](https://github.com/Tahul/zidane/blob/main/ui/src/theme/palette-of.ts#L17)

## Constants

### `DISABLED_OPACITY`

Constant.

One disabled look for every control.

```ts
const DISABLED_OPACITY = 0.5
```

Source: [ui/src/theme/scales.ts:31](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L31)

### `EASING`

Constant.

The easing curves (cubic-bezier control points) the tweens use.

```ts
const EASING: { readonly drawer: readonly [0.32, 0.72, 0, 1]; readonly fade: readonly [0.33, 1, 0.68, 1]; readonly in: readonly [0.4, 0, 1, 1]; readonly inOut: readonly [0.77, 0, 0.175, 1]; readonly out: readonly [0.23, 1, 0.32, 1] }
```

Source: [ui/src/theme/scales.ts:43](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L43)

### `FONT_SIZE`

Constant.

The interface type scale (outside the transcript and composer bodies):
`badge` count badges, `meta` the technical voice, `label` secondary text,
`ui` controls and rows, `body` reading text, `title` a page-sized view's heading.

```ts
const FONT_SIZE: { readonly badge: 10; readonly body: 14; readonly figure: 28; readonly label: 12; readonly meta: 11; readonly title: 20; readonly ui: 13 }
```

Source: [ui/src/theme/scales.ts:22](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L22)

### `PHONE_CODE_SIZE`

Constant.

The phone's code size: monospace reads larger than its point size, so a step under `subhead`.

```ts
const PHONE_CODE_SIZE = 14
```

Source: [ui/src/theme/scales.ts:93](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L93)

### `PHONE_TYPE`

Constant.

The phone's type scale. Phones read at arm's length: the steps follow the platforms' own
defaults (iOS Human Interface Guidelines), not the desktop's denser interface scale.
`largeTitle` a screen's title, `title` a sheet's, `headline` a row's title or a message's
author, `body` reading text (the transcript too), `subhead` secondary text in a row,
`footnote` metadata, `caption` the smallest text that is still read.

```ts
const PHONE_TYPE: { readonly body: { readonly ios: 'body'; readonly lineHeight: 22; readonly size: 17; readonly weight: '400' }; readonly caption: { readonly ios: 'caption1'; readonly lineHeight: 16; readonly size: 12; readonly weight: '400' }; readonly footnote: { readonly ios: 'footnote'; readonly lineHeight: 18; readonly size: 13; readonly weight: '400' }; readonly headline: { readonly ios: 'headline'; readonly lineHeight: 22; readonly size: 17; readonly weight: '600' }; readonly largeTitle: { readonly ios: 'largeTitle'; readonly lineHeight: 41; readonly size: 34; readonly weight: '700' }; readonly subhead: { readonly ios: 'subheadline'; readonly lineHeight: 20; readonly size: 15; readonly weight: '400' }; readonly title: { readonly ios: 'title2'; readonly lineHeight: 28; readonly size: 22; readonly weight: '700' } }
```

Source: [ui/src/theme/scales.ts:79](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L79)

### `RADIUS`

Constant.

Corner radius steps. Surfaces pick from them, never ad hoc.

```ts
const RADIUS: { readonly '2xl': 24; readonly lg: 12; readonly md: 8; readonly sm: 6; readonly xl: 16; readonly xs: 4 }
```

Source: [ui/src/theme/scales.ts:12](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L12)

### `READING_SIZE`

Constant.

The reading sizes: the transcript body (`chat`), the composer (`prompt`) and code.

```ts
const READING_SIZE: { readonly chat: 15; readonly code: 12; readonly prompt: 15 }
```

Source: [ui/src/theme/scales.ts:28](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L28)

### `SPACE`

Constant.

Spacing steps for native layouts (the web uses Uno's spacing): a 4-point
grid, from the hairline gap between stacked lines of text (`xxs`) to the space between sections (`xxl`).

```ts
const SPACE: { readonly lg: 16; readonly md: 12; readonly sm: 8; readonly xl: 24; readonly xs: 4; readonly xxl: 32; readonly xxs: 2 }
```

Source: [ui/src/theme/scales.ts:37](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L37)

## Interfaces

### `PhoneTypeStep`

Interface.

A step of the phone's type scale: its default size and line height, its weight, and the
platform text style it follows when the user changes the text size (iOS Dynamic Type, Android
font scale).

```ts
interface PhoneTypeStep
```

**Properties**

- `ios` (`'headline' | 'body' | 'largeTitle' | 'title2' | 'subheadline' | 'footnote' | 'caption1'`): The iOS text style it scales with.
- `lineHeight` (`number`): Line height at the default text size.
- `size` (`number`): Size at the default text size.
- `weight` (`'700' | '400' | '500' | '600'`): Weight, as CSS writes it.

Source: [ui/src/theme/scales.ts:61](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L61)

## Types

### `FontSizeStep`

Type.

A [`FONT_SIZE`](https://zidane.si/docs/reference/ui-theme.md#FONT_SIZE) step.

```ts
type FontSizeStep = keyof typeof FONT_SIZE
```

Source: [ui/src/theme/scales.ts:25](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L25)

### `LegacyThemePatch`

Type.

What a first run's appearance takes from a theme id: the slot the theme fills, and the mode that shows it.

```ts
type LegacyThemePatch =
  | { lightTheme: string; mode: 'light' }
  | { darkTheme: string; mode: 'dark' }
```

Source: [ui/src/theme/legacy-theme.ts:11](https://github.com/Tahul/zidane/blob/main/ui/src/theme/legacy-theme.ts#L11)

### `PhoneTypeName`

Type.

A [`PHONE_TYPE`](https://zidane.si/docs/reference/ui-theme.md#PHONE_TYPE) step.

```ts
type PhoneTypeName = keyof typeof PHONE_TYPE
```

Source: [ui/src/theme/scales.ts:90](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L90)

### `RadiusStep`

Type.

A [`RADIUS`](https://zidane.si/docs/reference/ui-theme.md#RADIUS) step.

```ts
type RadiusStep = keyof typeof RADIUS
```

Source: [ui/src/theme/scales.ts:15](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L15)

### `SpaceStep`

Type.

A [`SPACE`](https://zidane.si/docs/reference/ui-theme.md#SPACE) step.

```ts
type SpaceStep = keyof typeof SPACE
```

Source: [ui/src/theme/scales.ts:40](https://github.com/Tahul/zidane/blob/main/ui/src/theme/scales.ts#L40)

## Re-exports

These names are documented on the entry point that owns them.

- [theme/accents](https://zidane.si/docs/reference/ui-theme-accents.md): [`ACCENT_PRESETS`](https://zidane.si/docs/reference/ui-theme-accents.md#ACCENT_PRESETS), [`AccentPreset`](https://zidane.si/docs/reference/ui-theme-accents.md#AccentPreset)
- [theme/terminal-theme](https://zidane.si/docs/reference/ui-theme-terminal-theme.md): [`ansiColor`](https://zidane.si/docs/reference/ui-theme-terminal-theme.md#ansiColor), [`solid`](https://zidane.si/docs/reference/ui-theme-terminal-theme.md#solid), [`terminalTheme`](https://zidane.si/docs/reference/ui-theme-terminal-theme.md#terminalTheme), [`TerminalTheme`](https://zidane.si/docs/reference/ui-theme-terminal-theme.md#TerminalTheme)
- [theme/derive](https://zidane.si/docs/reference/ui-theme-derive.md): [`Appearance`](https://zidane.si/docs/reference/ui-theme-derive.md#Appearance), [`CONTRAST`](https://zidane.si/docs/reference/ui-theme-derive.md#CONTRAST), [`derivePalette`](https://zidane.si/docs/reference/ui-theme-derive.md#derivePalette), [`ResolvedPalette`](https://zidane.si/docs/reference/ui-theme-derive.md#ResolvedPalette), [`ThemeSeed`](https://zidane.si/docs/reference/ui-theme-derive.md#ThemeSeed)
- [theme/themes](https://zidane.si/docs/reference/ui-theme-themes.md): [`BUILTIN_THEMES`](https://zidane.si/docs/reference/ui-theme-themes.md#BUILTIN_THEMES), [`DEFAULT_THEME`](https://zidane.si/docs/reference/ui-theme-themes.md#DEFAULT_THEME), [`resolveTheme`](https://zidane.si/docs/reference/ui-theme-themes.md#resolveTheme), [`Theme`](https://zidane.si/docs/reference/ui-theme-themes.md#Theme)
- [theme/color](https://zidane.si/docs/reference/ui-theme-color.md): [`contrastRatio`](https://zidane.si/docs/reference/ui-theme-color.md#contrastRatio), [`mix`](https://zidane.si/docs/reference/ui-theme-color.md#mix), [`withAlpha`](https://zidane.si/docs/reference/ui-theme-color.md#withAlpha)
- [code/shiki-theme](https://zidane.si/docs/reference/ui-code-shiki-theme.md): [`defaultShikiTheme`](https://zidane.si/docs/reference/ui-code-shiki-theme.md#defaultShikiTheme), [`shikiThemeFor`](https://zidane.si/docs/reference/ui-code-shiki-theme.md#shikiThemeFor)
- [theme/motion-values](https://zidane.si/docs/reference/ui-theme-motion-values.md): [`MotionName`](https://zidane.si/docs/reference/ui-theme-motion-values.md#MotionName), [`MOTIONS`](https://zidane.si/docs/reference/ui-theme-motion-values.md#MOTIONS), [`MotionSpec`](https://zidane.si/docs/reference/ui-theme-motion-values.md#MotionSpec)
- [theme/from-theme](https://zidane.si/docs/reference/ui-theme-from-theme.md): [`seedFromTheme`](https://zidane.si/docs/reference/ui-theme-from-theme.md#seedFromTheme)
