# Theme Provider

> 为局部界面及其浮层配置主题，支持独立实例、嵌套覆盖和运行时切换。

网页来源：/components/theme-provider

版本：@quirekit/ui 0.3.1；源码修订：d79a6b48d00e+worktree。此文档对应当前源码构建，接入方式以开始使用为准。

接入前置：[开始使用](/raw/components/getting-started.md)（Vue、样式、主题与图标 Provider）。

`QuireThemeProvider` 为一组组件提供主题。适合编辑器实例、预览区或页面中的独立配色区域；
只需要统一全页外观时，也可以继续使用 [开始使用](/raw/components/getting-started.md#主题与浮层) 中的页面主题配置。

## 基本用法与嵌套

从 `@quirekit/ui/vue` 导入 `QuireThemeProvider`，从 `@quirekit/ui` 导入 `defaultTheme` 或 `createTheme`。
将完整的 `QuireKitTheme` 传给必填的 `theme`，默认插槽放置界面内容。
Vue、组件样式与图标的接入步骤见 [开始使用](/raw/components/getting-started.md)。

下面的按钮切换外层主题；内层 Provider 始终使用深色。分别打开两个选择列表，可以看到面板跟随各自最近的主题。

### 示例：getting-started/theme-scopes

文件：`theme-scopes.vue`

```vue
<script setup lang="ts">
import { shallowRef } from "vue";
import { createTheme, defaultTheme, quireIconRegistry } from "@quirekit/ui";
import { QuireButton, QuireIconProvider, QuireSelect, QuireThemeProvider } from "@quirekit/ui/vue";

const dark = createTheme({ scheme: "dark", sources: { primary: "#7257d5" } });
const theme = shallowRef(defaultTheme);
const value = shallowRef("document");
const items = [{ value: "document", label: "文档" }, { value: "presentation", label: "演示文稿" }];

/** Replaces the immutable theme while the select and its portal stay mounted. */
function toggleTheme(): void {
  theme.value = theme.value === dark ? defaultTheme : dark;
}
</script>

<template>
  <QuireIconProvider :registry="quireIconRegistry">
    <QuireThemeProvider :theme="theme">
      <section class="grid gap-4 bg-qk-surface-page p-6 text-qk-text-primary">
        <QuireButton @click="toggleTheme">切换局部主题</QuireButton>
        <QuireSelect v-model="value" :items="items" label="跟随局部主题" />
        <QuireThemeProvider :theme="dark">
          <div class="bg-qk-surface-page p-4 text-qk-text-primary">
            <QuireSelect v-model="value" :items="items" label="始终使用深色" />
          </div>
        </QuireThemeProvider>
      </section>
    </QuireThemeProvider>
  </QuireIconProvider>
</template>
```

主题对象按不可变值使用。通过替换 `theme` 的对象身份更新主题，不原地修改颜色或其他字段。
示例使用 `shallowRef` 保存主题，在切换时选择另一个完整对象；同一配置重复使用同一对象即可。
自定义主题参数见 [色彩](/raw/design/color.md) 与 [Token](/raw/design/tokens.md)。

## 独立实例

并列 Provider 分别管理各自的区域。文档区与预览区使用不同的主题色和明暗模式，切换一侧不会改变另一侧的主题或选值。

### 示例：theme-provider/instances

文件：`instances.vue`

```vue
<script setup lang="ts">
import { shallowRef } from "vue";
import { createTheme, quireIconRegistry } from "@quirekit/ui";
import { QuireButton, QuireIconProvider, QuireSelect, QuireThemeProvider } from "@quirekit/ui/vue";

const documentThemes = {
  light: createTheme({ scheme: "light", sources: { primary: "#7257d5" } }),
  dark: createTheme({ scheme: "dark", sources: { primary: "#7257d5" } })
};
const previewThemes = {
  light: createTheme({ scheme: "light", sources: { primary: "#0d9488" } }),
  dark: createTheme({ scheme: "dark", sources: { primary: "#0d9488" } })
};
const documentTheme = shallowRef(documentThemes.light);
const previewTheme = shallowRef(previewThemes.dark);
const format = shallowRef("document");
const mode = shallowRef("reading");
const formats = [{ value: "document", label: "文档" }, { value: "presentation", label: "演示文稿" }];
const modes = [{ value: "reading", label: "阅读" }, { value: "print", label: "打印预览" }];

/** Replaces only the document region's immutable theme. */
function toggleDocumentTheme(): void {
  documentTheme.value = documentTheme.value === documentThemes.light ? documentThemes.dark : documentThemes.light;
}

/** Replaces only the preview region's immutable theme. */
function togglePreviewTheme(): void {
  previewTheme.value = previewTheme.value === previewThemes.light ? previewThemes.dark : previewThemes.light;
}
</script>

<template>
  <QuireIconProvider :registry="quireIconRegistry">
    <div class="grid gap-4 p-4 md:grid-cols-2">
      <QuireThemeProvider :theme="documentTheme">
        <section class="grid min-w-0 content-start gap-4 rounded-lg bg-qk-surface-page p-6 text-qk-text-primary" aria-label="文档区">
          <div>
            <h3 class="m-0 text-base font-semibold">文档区</h3>
            <p class="mb-0 mt-1 text-sm text-qk-text-secondary">紫色主题 · {{ documentTheme.scheme === 'light' ? '浅色' : '深色' }}</p>
          </div>
          <QuireSelect v-model="format" :items="formats" label="文档区格式" width="100%" />
          <QuireButton color="primary" variant="solid" @click="toggleDocumentTheme">切换文档区明暗</QuireButton>
        </section>
      </QuireThemeProvider>
      <QuireThemeProvider :theme="previewTheme">
        <section class="grid min-w-0 content-start gap-4 rounded-lg bg-qk-surface-page p-6 text-qk-text-primary" aria-label="预览区">
          <div>
            <h3 class="m-0 text-base font-semibold">预览区</h3>
            <p class="mb-0 mt-1 text-sm text-qk-text-secondary">青色主题 · {{ previewTheme.scheme === 'light' ? '浅色' : '深色' }}</p>
          </div>
          <QuireSelect v-model="mode" :items="modes" label="预览区模式" width="100%" />
          <QuireButton color="primary" variant="solid" @click="togglePreviewTheme">切换预览区明暗</QuireButton>
        </section>
      </QuireThemeProvider>
    </div>
  </QuireIconProvider>
</template>
```

## 浮层与局部覆盖

公共组件自带的浮层自动继承最近的 Provider，包括 Select、Combobox 的选择面板、Menu、Tooltip、
Popover、Dialog、Drawer，以及组合组件使用的浮层。面板传送到 `body` 后也保留所属实例的主题，
主题切换同时作用于区域内控件和已打开的面板，无需给每个 `contentProps.style` 重复传入完整主题变量。

组件支持的 `style`、`contentProps.style` 仍可用于显式业务覆盖；语言和阅读方向按各组件公开的属性配置。
CodeBlock 与 ImagePreview 自身的 `scheme` 设置继续遵循各自的局部外观合同。
没有 Provider 时，组件继续使用全页 CSS 主题，已有的手动样式覆盖方式也仍然有效。

## 布局与属性

Provider 不提供布局盒，也不接受 HTML attrs、`class`、`style` 或布局 props。
把宽度、间距、背景、事件及可访问属性放在默认插槽中的业务元素上：

```vue
<QuireThemeProvider :theme="theme">
  <section class="grid gap-4 bg-qk-surface-page p-6 text-qk-text-primary" aria-label="文档设置">
    <!-- 这里放置使用该主题的组件。 -->
  </section>
</QuireThemeProvider>
```

框架或产品壳已经把同一主题变量投影到一个真实实例根时，可以使用 `surface="false"`，让
Provider 只负责跨 Teleport 的 Vue 逻辑 context，避免在实例内部重复生成完整变量层。普通业务
界面不要使用该模式：没有外部变量根时，slot 内容将不会凭空获得主题 CSS 变量。

## 独立应用与服务端渲染

同一个 Vue 应用中的嵌套内容使用最近的 Provider。通过 `createApp` 单独挂载的 Vue 根需要各自配置 Provider，
即使挂载点在另一个主题区域内，也不能代替该独立应用的主题配置。
服务端渲染时，在服务端和客户端首次渲染传入一致的主题。

Provider 不改变浮层的传送目标，也不为组件增加 `portalTarget` 属性。需要自定义目标时，
先查阅所用组件的 API；支持传送到另一 Document 的组件，仍要求宿主为目标文档安装组件 CSS。
应用自行创建的 Teleport 内容需要自行安排主题边界。

## API

必填 prop 是 `theme: QuireKitTheme`，没有默认主题值；高级可选 prop `surface` 默认为 `true`。
`default` 插槽接收界面内容，不提供插槽参数；Provider 没有额外事件或公开实例方法。

### QuireThemeProvider

#### Props

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| theme | 是 | — |  |
| surface | 否 | true |  |

**theme**

```ts
QuireKitTheme
```

```ts
{
  /** Theme profile that supplies values for the semantic-token contract. */
  profile: "precision" | "ink" | "slate" | "stone";
  /** Owning light or dark projection. */
  scheme: "light" | "dark";
  /** Source roles selected by the theme profile. */
  sources: {
    /** Product focus and primary-action source. */
    primary: string;
    /** Informational and processing source. */
    info: string;
    /** Successful-outcome source. */
    success: string;
    /** Recoverable-risk source. */
    warning: string;
    /** Error and destructive-action source. */
    danger: string;
  };
  /** Generated atomic palettes used during semantic projection. */
  scales: {
    /** Manually reviewed neutral palette. */
    neutral: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated product primary palette. */
    primary: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated informational palette. */
    info: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated success palette. */
    success: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated warning palette. */
    warning: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated danger palette. */
    danger: Readonly<Record<QuireKitColorStep, string>>;
  };
  /** Reverse-composited transparent palettes paired with the solid scales. */
  alphaScales: QuireKitThemeColorScales;
  /** Semantic color roles consumed by future component tokens. */
  color: {
    /** Surface roles. */
    surface: {
      /** Fully transparent surface derived from the zero-opacity base token. */
      transparent: string;
      /** Editor workspace outside document pages. */
      workspace: string;
      /** Document page or paper surface. */
      page: string;
      /** Persistent toolbar, rail, and product chrome. */
      chrome: string;
      /** Quiet grouping and control-track surface. */
      subtle: string;
      /** Locally raised non-modal surface. */
      raised: string;
      /** Menu, popover, and quick-bar surface. */
      overlay: string;
      /** Neutral solid and inverted chrome background, paired with text.inverse. */
      inverse: string;
      /** Neutral pointer-hover surface. */
      hover: string;
      /** Neutral pressed surface. */
      pressed: string;
      /** Persistent neutral selected surface. */
      selected: string;
      /** Unavailable-control surface. */
      disabled: string;
      /** Modal and task-workspace scrim. */
      scrim: string;
    };
    /** Text roles. */
    text: {
      /** Highest-contrast headings, body copy, entered values, and primary labels. */
      primary: string;
      /** Supporting product text. */
      secondary: string;
      /** Metadata readable across neutral interaction surfaces. */
      tertiary: string;
      /** Quiet readable hints on static neutral surfaces. */
      muted: string;
      /** Empty-input prompts readable on field and hover surfaces. */
      placeholder: string;
      /** Accent on neutral surfaces: source six in light mode, step nine in dark mode; neutral themes retain their action identity. */
      accent: string;
      /** Unavailable text. */
      disabled: string;
      /** Text shown on inverted chrome. */
      inverse: string;
      /** Text shown on the primary solid action. */
      onAccent: string;
    };
    /** Icon roles. */
    icon: {
      /** Primary icon color. */
      primary: string;
      /** Supporting icon color. */
      secondary: string;
      /** Unavailable icon color. */
      disabled: string;
      /** Icon shown on the primary solid action. */
      onAccent: string;
    };
    /** Boundary roles. */
    border: {
      /** Quiet structural separator. */
      subtle: string;
      /** Default control or surface boundary. */
      default: string;
      /** Strong input or resizable-structure boundary. */
      strong: string;
      /** Keyboard-focus boundary. */
      focus: string;
      /** Unavailable-control boundary. */
      disabled: string;
    };
    /** Primary action roles. */
    action: {
      /** Primary solid action. */
      primary: string;
      /** Existing palette token from steps six through eight in light mode and step nine in dark mode; neutral actions use their solid token. */
      text: string;
      /** Primary solid action hover. */
      hover: string;
      /** Primary solid action pressed state. */
      pressed: string;
      /** Quiet accent-tinted explanatory surface. */
      soft: string;
      /** Accent-tinted surface under pointer hover. */
      softHover: string;
      /** Accent-tinted surface while pressed. */
      softPressed: string;
      /** Content shown on the primary solid action. */
      foreground: string;
    };
    /** Informational feedback roles. */
    info: {
      /** Quiet feedback surface. */
      surface: string;
      /** Feedback surface under pointer hover. */
      hoverSurface: string;
      /** Feedback surface while pressed. */
      pressedSurface: string;
      /** Feedback boundary. */
      border: string;
      /** Existing palette token from steps six through eight in light mode and step nine in dark mode for feedback text and icons. */
      text: string;
      /** Feedback text and icon. */
      foreground: string;
      /** Solid feedback action or marker. */
      solid: string;
      /** Content shown on the solid feedback color. */
      onSolid: string;
    };
    /** Successful-outcome feedback roles. */
    success: QuireKitSemanticFeedbackTokens;
    /** Recoverable-risk feedback roles. */
    warning: QuireKitSemanticFeedbackTokens;
    /** Error and destructive-action feedback roles. */
    danger: QuireKitSemanticFeedbackTokens;
    /** Selection and direct-manipulation roles. */
    selection: {
      /** Authored document text or object selection. */
      document: string;
      /** Remote collaborator selection placeholder. */
      remote: string;
      /** Valid drag-and-drop target. */
      dropTarget: string;
    };
  };
  /** Semantic typography roles. */
  typography: {
    /** Large design-site or empty-state display title. */
    display: {
      /** Font-family stack. */
      fontFamily: string;
      /** Font size. */
      fontSize: string;
      /** Line height. */
      lineHeight: string;
      /** Font weight. */
      fontWeight: number;
      /** Letter spacing. */
      letterSpacing: string;
    };
    /** Product page title. */
    pageTitle: QuireKitSemanticTypographyRole;
    /** Major section title. */
    sectionTitle: QuireKitSemanticTypographyRole;
    /** Local card, panel, or dialog heading. */
    heading: QuireKitSemanticTypographyRole;
    /** Default reading and product body text. */
    body: QuireKitSemanticTypographyRole;
    /** Button, input, and menu label. */
    control: QuireKitSemanticTypographyRole;
    /** Dense value and compact metadata. */
    compact: QuireKitSemanticTypographyRole;
    /** Supporting explanation. */
    helper: QuireKitSemanticTypographyRole;
    /** Code and keyboard shortcut text. */
    code: QuireKitSemanticTypographyRole;
  };
  /** Semantic spacing roles. */
  spacing: {
    /** Tight icon-to-label gap. */
    inlineTight: string;
    /** Regular inline gap. */
    inline: string;
    /** Internal compact-surface padding. */
    surfaceCompact: string;
    /** Internal regular-surface padding. */
    surface: string;
    /** Related-control group gap. */
    group: string;
    /** Section-to-section gap. */
    section: string;
    /** Page-edge gap. */
    page: string;
    /** Major composition gap. */
    major: string;
  };
  /** Semantic corner roles. */
  radius: {
    /** Document page corner. */
    page: string;
    /** Interactive-control corner. */
    control: string;
    /** Grouped-control track corner. */
    group: string;
    /** Menu and popover corner. */
    overlay: string;
    /** Dialog corner. */
    dialog: string;
    /** Pill and circular corner. */
    pill: string;
  };
  /** Semantic border widths. */
  borderWidth: {
    /** No visible boundary. */
    none: string;
    /** Default structural boundary. */
    default: string;
    /** Keyboard-focus boundary. */
    focus: string;
  };
  /** Semantic elevation roles. */
  elevation: {
    /** Flat surface. */
    flat: string;
    /** Raised local surface. */
    raised: string;
    /** Menu or popover surface. */
    overlay: string;
    /** Modal task surface. */
    modal: string;
  };
  /** Semantic motion roles. */
  motion: {
    /** Hover or pressed feedback duration. */
    feedbackDuration: string;
    /** Standard control transition duration. */
    controlDuration: string;
    /** Overlay transition duration. */
    overlayDuration: string;
    /** Standard state easing. */
    standardEasing: string;
    /** Overlay entrance easing. */
    enterEasing: string;
    /** Overlay exit easing. */
    exitEasing: string;
  };
  /** Semantic opacity states mapped from the numeric base scale. */
  opacity: {
    /** Fully transparent content. */
    transparent: number;
    /** Disabled control content. */
    disabled: number;
    /** Muted supporting content. */
    muted: number;
    /** Drag preview content. */
    drag: number;
    /** Pressed control intensity without changing its color role. */
    pressed: number;
    /** Hovered control intensity without changing its color role. */
    hover: number;
    /** Fully opaque content. */
    opaque: number;
  };
  /** Semantic layer roles. */
  layer: {
    /** Normal content. */
    base: number;
    /** Sticky chrome. */
    chrome: number;
    /** Menus and popovers. */
    overlay: number;
    /** Dialogs. */
    modal: number;
    /** Toast notifications. */
    toast: number;
    /** Tooltips. */
    tooltip: number;
  };
  /** Four public component-size roles. */
  control: {
    /** Pointer-oriented dense-toolbar control height. */
    compact: string;
    /** Default editor control height. */
    default: string;
    /** Regular form and popover control height. */
    regular: string;
    /** Comfortable dialog and inspector control height. */
    comfortable: string;
    /** Large visible control height for touch-oriented surfaces. */
    large: string;
    /** Default icon box. */
    icon: string;
    /** Large icon box. */
    iconLarge: string;
    /** Enhanced pointer target for touch input, independent of visible height. */
    touchTarget: string;
  };
}
```

**surface**

```ts
boolean | undefined
```

#### Events

无。

#### Slots

| 名称 | 必填 | 默认值 | 说明 |
| --- | --- | --- | --- |
| default | 否 | — |  |

**default**

```ts
{}
```

#### 公开实例成员

无。

#### 相关类型

```ts
type QuireKitTheme = {
  /** Theme profile that supplies values for the semantic-token contract. */
  profile: "precision" | "ink" | "slate" | "stone";
  /** Owning light or dark projection. */
  scheme: "light" | "dark";
  /** Source roles selected by the theme profile. */
  sources: {
    /** Product focus and primary-action source. */
    primary: string;
    /** Informational and processing source. */
    info: string;
    /** Successful-outcome source. */
    success: string;
    /** Recoverable-risk source. */
    warning: string;
    /** Error and destructive-action source. */
    danger: string;
  };
  /** Generated atomic palettes used during semantic projection. */
  scales: {
    /** Manually reviewed neutral palette. */
    neutral: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated product primary palette. */
    primary: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated informational palette. */
    info: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated success palette. */
    success: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated warning palette. */
    warning: Readonly<Record<QuireKitColorStep, string>>;
    /** Generated danger palette. */
    danger: Readonly<Record<QuireKitColorStep, string>>;
  };
  /** Reverse-composited transparent palettes paired with the solid scales. */
  alphaScales: QuireKitThemeColorScales;
  /** Semantic color roles consumed by future component tokens. */
  color: {
    /** Surface roles. */
    surface: QuireKitSemanticSurfaceTokens;
    /** Text roles. */
    text: QuireKitSemanticTextTokens;
    /** Icon roles. */
    icon: QuireKitSemanticIconTokens;
    /** Boundary roles. */
    border: QuireKitSemanticBorderTokens;
    /** Primary action roles. */
    action: QuireKitSemanticActionTokens;
    /** Informational feedback roles. */
    info: QuireKitSemanticFeedbackTokens;
    /** Successful-outcome feedback roles. */
    success: QuireKitSemanticFeedbackTokens;
    /** Recoverable-risk feedback roles. */
    warning: QuireKitSemanticFeedbackTokens;
    /** Error and destructive-action feedback roles. */
    danger: QuireKitSemanticFeedbackTokens;
    /** Selection and direct-manipulation roles. */
    selection: QuireKitSemanticSelectionTokens;
  };
  /** Semantic typography roles. */
  typography: {
    /** Large design-site or empty-state display title. */
    display: QuireKitSemanticTypographyRole;
    /** Product page title. */
    pageTitle: QuireKitSemanticTypographyRole;
    /** Major section title. */
    sectionTitle: QuireKitSemanticTypographyRole;
    /** Local card, panel, or dialog heading. */
    heading: QuireKitSemanticTypographyRole;
    /** Default reading and product body text. */
    body: QuireKitSemanticTypographyRole;
    /** Button, input, and menu label. */
    control: QuireKitSemanticTypographyRole;
    /** Dense value and compact metadata. */
    compact: QuireKitSemanticTypographyRole;
    /** Supporting explanation. */
    helper: QuireKitSemanticTypographyRole;
    /** Code and keyboard shortcut text. */
    code: QuireKitSemanticTypographyRole;
  };
  /** Semantic spacing roles. */
  spacing: {
    /** Tight icon-to-label gap. */
    inlineTight: string;
    /** Regular inline gap. */
    inline: string;
    /** Internal compact-surface padding. */
    surfaceCompact: string;
    /** Internal regular-surface padding. */
    surface: string;
    /** Related-control group gap. */
    group: string;
    /** Section-to-section gap. */
    section: string;
    /** Page-edge gap. */
    page: string;
    /** Major composition gap. */
    major: string;
  };
  /** Semantic corner roles. */
  radius: {
    /** Document page corner. */
    page: string;
    /** Interactive-control corner. */
    control: string;
    /** Grouped-control track corner. */
    group: string;
    /** Menu and popover corner. */
    overlay: string;
    /** Dialog corner. */
    dialog: string;
    /** Pill and circular corner. */
    pill: string;
  };
  /** Semantic border widths. */
  borderWidth: {
    /** No visible boundary. */
    none: string;
    /** Default structural boundary. */
    default: string;
    /** Keyboard-focus boundary. */
    focus: string;
  };
  /** Semantic elevation roles. */
  elevation: {
    /** Flat surface. */
    flat: string;
    /** Raised local surface. */
    raised: string;
    /** Menu or popover surface. */
    overlay: string;
    /** Modal task surface. */
    modal: string;
  };
  /** Semantic motion roles. */
  motion: {
    /** Hover or pressed feedback duration. */
    feedbackDuration: string;
    /** Standard control transition duration. */
    controlDuration: string;
    /** Overlay transition duration. */
    overlayDuration: string;
    /** Standard state easing. */
    standardEasing: string;
    /** Overlay entrance easing. */
    enterEasing: string;
    /** Overlay exit easing. */
    exitEasing: string;
  };
  /** Semantic opacity states mapped from the numeric base scale. */
  opacity: {
    /** Fully transparent content. */
    transparent: number;
    /** Disabled control content. */
    disabled: number;
    /** Muted supporting content. */
    muted: number;
    /** Drag preview content. */
    drag: number;
    /** Pressed control intensity without changing its color role. */
    pressed: number;
    /** Hovered control intensity without changing its color role. */
    hover: number;
    /** Fully opaque content. */
    opaque: number;
  };
  /** Semantic layer roles. */
  layer: {
    /** Normal content. */
    base: number;
    /** Sticky chrome. */
    chrome: number;
    /** Menus and popovers. */
    overlay: number;
    /** Dialogs. */
    modal: number;
    /** Toast notifications. */
    toast: number;
    /** Tooltips. */
    tooltip: number;
  };
  /** Four public component-size roles. */
  control: {
    /** Pointer-oriented dense-toolbar control height. */
    compact: string;
    /** Default editor control height. */
    default: string;
    /** Regular form and popover control height. */
    regular: string;
    /** Comfortable dialog and inspector control height. */
    comfortable: string;
    /** Large visible control height for touch-oriented surfaces. */
    large: string;
    /** Default icon box. */
    icon: string;
    /** Large icon box. */
    iconLarge: string;
    /** Enhanced pointer target for touch input, independent of visible height. */
    touchTarget: string;
  };
};
```

```ts
type QuireKitNeutralPalette = "precision" | "ink" | "slate" | "stone";
```

```ts
type QuireKitColorScheme = "light" | "dark";
```

```ts
type QuireKitThemeColorSources = {
  /** Product focus and primary-action source. */
  primary: string;
  /** Informational and processing source. */
  info: string;
  /** Successful-outcome source. */
  success: string;
  /** Recoverable-risk source. */
  warning: string;
  /** Error and destructive-action source. */
  danger: string;
};
```

```ts
type QuireKitThemeColorScales = QuireKitThemeColorScales;
```

```ts
type QuireKitSemanticColorTokens = {
  /** Surface roles. */
  surface: {
    /** Fully transparent surface derived from the zero-opacity base token. */
    transparent: string;
    /** Editor workspace outside document pages. */
    workspace: string;
    /** Document page or paper surface. */
    page: string;
    /** Persistent toolbar, rail, and product chrome. */
    chrome: string;
    /** Quiet grouping and control-track surface. */
    subtle: string;
    /** Locally raised non-modal surface. */
    raised: string;
    /** Menu, popover, and quick-bar surface. */
    overlay: string;
    /** Neutral solid and inverted chrome background, paired with text.inverse. */
    inverse: string;
    /** Neutral pointer-hover surface. */
    hover: string;
    /** Neutral pressed surface. */
    pressed: string;
    /** Persistent neutral selected surface. */
    selected: string;
    /** Unavailable-control surface. */
    disabled: string;
    /** Modal and task-workspace scrim. */
    scrim: string;
  };
  /** Text roles. */
  text: {
    /** Highest-contrast headings, body copy, entered values, and primary labels. */
    primary: string;
    /** Supporting product text. */
    secondary: string;
    /** Metadata readable across neutral interaction surfaces. */
    tertiary: string;
    /** Quiet readable hints on static neutral surfaces. */
    muted: string;
    /** Empty-input prompts readable on field and hover surfaces. */
    placeholder: string;
    /** Accent on neutral surfaces: source six in light mode, step nine in dark mode; neutral themes retain their action identity. */
    accent: string;
    /** Unavailable text. */
    disabled: string;
    /** Text shown on inverted chrome. */
    inverse: string;
    /** Text shown on the primary solid action. */
    onAccent: string;
  };
  /** Icon roles. */
  icon: {
    /** Primary icon color. */
    primary: string;
    /** Supporting icon color. */
    secondary: string;
    /** Unavailable icon color. */
    disabled: string;
    /** Icon shown on the primary solid action. */
    onAccent: string;
  };
  /** Boundary roles. */
  border: {
    /** Quiet structural separator. */
    subtle: string;
    /** Default control or surface boundary. */
    default: string;
    /** Strong input or resizable-structure boundary. */
    strong: string;
    /** Keyboard-focus boundary. */
    focus: string;
    /** Unavailable-control boundary. */
    disabled: string;
  };
  /** Primary action roles. */
  action: {
    /** Primary solid action. */
    primary: string;
    /** Existing palette token from steps six through eight in light mode and step nine in dark mode; neutral actions use their solid token. */
    text: string;
    /** Primary solid action hover. */
    hover: string;
    /** Primary solid action pressed state. */
    pressed: string;
    /** Quiet accent-tinted explanatory surface. */
    soft: string;
    /** Accent-tinted surface under pointer hover. */
    softHover: string;
    /** Accent-tinted surface while pressed. */
    softPressed: string;
    /** Content shown on the primary solid action. */
    foreground: string;
  };
  /** Informational feedback roles. */
  info: {
    /** Quiet feedback surface. */
    surface: string;
    /** Feedback surface under pointer hover. */
    hoverSurface: string;
    /** Feedback surface while pressed. */
    pressedSurface: string;
    /** Feedback boundary. */
    border: string;
    /** Existing palette token from steps six through eight in light mode and step nine in dark mode for feedback text and icons. */
    text: string;
    /** Feedback text and icon. */
    foreground: string;
    /** Solid feedback action or marker. */
    solid: string;
    /** Content shown on the solid feedback color. */
    onSolid: string;
  };
  /** Successful-outcome feedback roles. */
  success: QuireKitSemanticFeedbackTokens;
  /** Recoverable-risk feedback roles. */
  warning: QuireKitSemanticFeedbackTokens;
  /** Error and destructive-action feedback roles. */
  danger: QuireKitSemanticFeedbackTokens;
  /** Selection and direct-manipulation roles. */
  selection: {
    /** Authored document text or object selection. */
    document: string;
    /** Remote collaborator selection placeholder. */
    remote: string;
    /** Valid drag-and-drop target. */
    dropTarget: string;
  };
};
```

```ts
type QuireKitSemanticSurfaceTokens = {
  /** Fully transparent surface derived from the zero-opacity base token. */
  transparent: string;
  /** Editor workspace outside document pages. */
  workspace: string;
  /** Document page or paper surface. */
  page: string;
  /** Persistent toolbar, rail, and product chrome. */
  chrome: string;
  /** Quiet grouping and control-track surface. */
  subtle: string;
  /** Locally raised non-modal surface. */
  raised: string;
  /** Menu, popover, and quick-bar surface. */
  overlay: string;
  /** Neutral solid and inverted chrome background, paired with text.inverse. */
  inverse: string;
  /** Neutral pointer-hover surface. */
  hover: string;
  /** Neutral pressed surface. */
  pressed: string;
  /** Persistent neutral selected surface. */
  selected: string;
  /** Unavailable-control surface. */
  disabled: string;
  /** Modal and task-workspace scrim. */
  scrim: string;
};
```

```ts
type QuireKitSemanticTextTokens = {
  /** Highest-contrast headings, body copy, entered values, and primary labels. */
  primary: string;
  /** Supporting product text. */
  secondary: string;
  /** Metadata readable across neutral interaction surfaces. */
  tertiary: string;
  /** Quiet readable hints on static neutral surfaces. */
  muted: string;
  /** Empty-input prompts readable on field and hover surfaces. */
  placeholder: string;
  /** Accent on neutral surfaces: source six in light mode, step nine in dark mode; neutral themes retain their action identity. */
  accent: string;
  /** Unavailable text. */
  disabled: string;
  /** Text shown on inverted chrome. */
  inverse: string;
  /** Text shown on the primary solid action. */
  onAccent: string;
};
```

```ts
type QuireKitSemanticIconTokens = {
  /** Primary icon color. */
  primary: string;
  /** Supporting icon color. */
  secondary: string;
  /** Unavailable icon color. */
  disabled: string;
  /** Icon shown on the primary solid action. */
  onAccent: string;
};
```

```ts
type QuireKitSemanticBorderTokens = {
  /** Quiet structural separator. */
  subtle: string;
  /** Default control or surface boundary. */
  default: string;
  /** Strong input or resizable-structure boundary. */
  strong: string;
  /** Keyboard-focus boundary. */
  focus: string;
  /** Unavailable-control boundary. */
  disabled: string;
};
```

```ts
type QuireKitSemanticActionTokens = {
  /** Primary solid action. */
  primary: string;
  /** Existing palette token from steps six through eight in light mode and step nine in dark mode; neutral actions use their solid token. */
  text: string;
  /** Primary solid action hover. */
  hover: string;
  /** Primary solid action pressed state. */
  pressed: string;
  /** Quiet accent-tinted explanatory surface. */
  soft: string;
  /** Accent-tinted surface under pointer hover. */
  softHover: string;
  /** Accent-tinted surface while pressed. */
  softPressed: string;
  /** Content shown on the primary solid action. */
  foreground: string;
};
```

```ts
type QuireKitSemanticFeedbackTokens = QuireKitSemanticFeedbackTokens;
```

```ts
type QuireKitSemanticSelectionTokens = {
  /** Authored document text or object selection. */
  document: string;
  /** Remote collaborator selection placeholder. */
  remote: string;
  /** Valid drag-and-drop target. */
  dropTarget: string;
};
```

```ts
type QuireKitSemanticTypographyTokens = {
  /** Large design-site or empty-state display title. */
  display: {
    /** Font-family stack. */
    fontFamily: string;
    /** Font size. */
    fontSize: string;
    /** Line height. */
    lineHeight: string;
    /** Font weight. */
    fontWeight: number;
    /** Letter spacing. */
    letterSpacing: string;
  };
  /** Product page title. */
  pageTitle: QuireKitSemanticTypographyRole;
  /** Major section title. */
  sectionTitle: QuireKitSemanticTypographyRole;
  /** Local card, panel, or dialog heading. */
  heading: QuireKitSemanticTypographyRole;
  /** Default reading and product body text. */
  body: QuireKitSemanticTypographyRole;
  /** Button, input, and menu label. */
  control: QuireKitSemanticTypographyRole;
  /** Dense value and compact metadata. */
  compact: QuireKitSemanticTypographyRole;
  /** Supporting explanation. */
  helper: QuireKitSemanticTypographyRole;
  /** Code and keyboard shortcut text. */
  code: QuireKitSemanticTypographyRole;
};
```

```ts
type QuireKitSemanticTypographyRole = QuireKitSemanticTypographyRole;
```

```ts
type QuireKitSemanticSpacingTokens = {
  /** Tight icon-to-label gap. */
  inlineTight: string;
  /** Regular inline gap. */
  inline: string;
  /** Internal compact-surface padding. */
  surfaceCompact: string;
  /** Internal regular-surface padding. */
  surface: string;
  /** Related-control group gap. */
  group: string;
  /** Section-to-section gap. */
  section: string;
  /** Page-edge gap. */
  page: string;
  /** Major composition gap. */
  major: string;
};
```

```ts
type QuireKitSemanticRadiusTokens = {
  /** Document page corner. */
  page: string;
  /** Interactive-control corner. */
  control: string;
  /** Grouped-control track corner. */
  group: string;
  /** Menu and popover corner. */
  overlay: string;
  /** Dialog corner. */
  dialog: string;
  /** Pill and circular corner. */
  pill: string;
};
```

```ts
type QuireKitSemanticBorderWidthTokens = {
  /** No visible boundary. */
  none: string;
  /** Default structural boundary. */
  default: string;
  /** Keyboard-focus boundary. */
  focus: string;
};
```

```ts
type QuireKitSemanticElevationTokens = {
  /** Flat surface. */
  flat: string;
  /** Raised local surface. */
  raised: string;
  /** Menu or popover surface. */
  overlay: string;
  /** Modal task surface. */
  modal: string;
};
```

```ts
type QuireKitSemanticMotionTokens = {
  /** Hover or pressed feedback duration. */
  feedbackDuration: string;
  /** Standard control transition duration. */
  controlDuration: string;
  /** Overlay transition duration. */
  overlayDuration: string;
  /** Standard state easing. */
  standardEasing: string;
  /** Overlay entrance easing. */
  enterEasing: string;
  /** Overlay exit easing. */
  exitEasing: string;
};
```

```ts
type QuireKitSemanticOpacityTokens = {
  /** Fully transparent content. */
  transparent: number;
  /** Disabled control content. */
  disabled: number;
  /** Muted supporting content. */
  muted: number;
  /** Drag preview content. */
  drag: number;
  /** Pressed control intensity without changing its color role. */
  pressed: number;
  /** Hovered control intensity without changing its color role. */
  hover: number;
  /** Fully opaque content. */
  opaque: number;
};
```

```ts
type QuireKitSemanticLayerTokens = {
  /** Normal content. */
  base: number;
  /** Sticky chrome. */
  chrome: number;
  /** Menus and popovers. */
  overlay: number;
  /** Dialogs. */
  modal: number;
  /** Toast notifications. */
  toast: number;
  /** Tooltips. */
  tooltip: number;
};
```

```ts
type QuireKitSemanticControlTokens = {
  /** Pointer-oriented dense-toolbar control height. */
  compact: string;
  /** Default editor control height. */
  default: string;
  /** Regular form and popover control height. */
  regular: string;
  /** Comfortable dialog and inspector control height. */
  comfortable: string;
  /** Large visible control height for touch-oriented surfaces. */
  large: string;
  /** Default icon box. */
  icon: string;
  /** Large icon box. */
  iconLarge: string;
  /** Enhanced pointer target for touch input, independent of visible height. */
  touchTarget: string;
};
```
