@hanzo/appearance

中文文档
0.2.15发布于 2026/11/13MITTypeScriptESM + CJS近 30 天下载 1.9万

A person's own reading of the Hanzo design system — theme, type size, density, corners, accent — stored, applied and adjustable.

原始使用文档
文档目录4 节
  1. Knobs, not themes
  2. First paint
  3. Where a choice lives
  4. The composer

@hanzo/appearance

The one appearance panel: theme, text size, scale, density, face, Arabic face, width, corners and accent, stored per person and applied to the whole product.

import { Appearance } from '@hanzo/appearance'

<Appearance />

Add the boot script to <head> so the first paint is already correct — without it the page paints at the defaults and jumps when JS runs:

import { bootScript } from '@hanzo/appearance/state'

<script dangerouslySetInnerHTML={{ __html: bootScript() }} />

<Hanzo> from @hanzo/ui applies the person's choice on mount and hands gui the theme the document shows. A host that mounts its own gui provider calls useAppearance() once at its root and passes useScheme() as defaultTheme.

Knobs, not themes

@hanzo/design publishes --type-scale, --type-ratio, --density, --radius-scale, --font-sans, --font-arabic and the --primary / --accent family, and every ramp in tokens/*.css reads them. A preference sets a few numbers and one colour rather than restating a scale, so rungs added later are covered for free.

Arabic is its own axis (arabic: kufi, sans or plex) because Zen draws no Arabic. It writes --font-arabic, which design's sans, mono and serif stacks all name first, so the companion it names sets every Arabic letter under whichever face was chosen, and Latin never touches it.

An accent is a family: the fill, the ink that reads on it (design's black or white, whichever contrasts more) and the hover that deepens it, all derived from the one colour by vars(). The theme is a class, light / t_light or dark / t_dark, painted on <html> in both vocabularies.

First paint

apply() keeps what it painted under hanzo.appearance.painted, and bootScript() replays exactly that before any bundle runs. It computes nothing, so it cannot fall behind vars(). bootScript({ base }) paints an install default on a device that has never applied anything.

Where a choice lives

Four layers, the narrowest that has an opinion winning axis by axis: install < org < person (everywhere) < person (this org). The person's layers are kept in IAM (/v1/iam/preferences, member appearance) and cached on the device, so a choice made on one Hanzo origin reaches the others.

The composer

How a person's composer behaves is one record, read by every composer (@hanzo/ui/chat's Composer) and written by the panel's last rows:

import { useComposing, writeComposing } from '@hanzo/appearance'

useComposing() // { send?: 'enter' | 'mod', chips?: boolean, model?: boolean, mode?: boolean }
writeComposing({ send: 'mod' }) // ⌘/Ctrl+Enter sends, Enter breaks the line

An axis nobody set is absent, and the surface's own default holds (Chat opens without chips or a mode, Dev with both; the model selector is off until turned on). It is kept on the device under hanzo.composer, announced to the page with a hanzo:composer event, and kept in IAM beside the appearance under the composer member of /v1/iam/preferences, so it crosses a domain. It paints nothing: no document knob, no head script.

版本与发布记录

@hanzo/appearance 共发布 23 个版本,首次发布于 2026/08/08;过去 12 个月发布了 23 个版本。

版本发布日期距今
0.2.15latest2026/11/134 天前
0.2.142026/11/0710 天前
0.2.132026/10/3018 天前
0.2.122026/10/2621 天前
0.2.112026/10/2325 天前
0.2.102026/10/171 个月前

关于 @hanzo/appearance 的常见问题

@hanzo/appearance 是什么?

A person's own reading of the Hanzo design system — theme, type size, density, corners, accent — stored, applied and adjustable.

如何安装 @hanzo/appearance?

在项目目录运行 npm install @hanzo/appearance,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19.2.8)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@hanzo/appearance 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@hanzo/appearance 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@hanzo/appearance 可以商用吗?

@hanzo/appearance 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@hanzo/appearance 的下载量有多少?

根据 npm 官方下载统计,@hanzo/appearance 在 2026/10/17 – 2026/11/15 这 30 天内被下载 18,736 次,日均约 625 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@hanzo/appearance 还在维护吗?

最新版本 0.2.15 发布于 2026/11/13(4 天前);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/08/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。