@hanzo/composer

中文文档
0.2.1发布于 2026/10/31MITTypeScriptES Module零依赖近 30 天下载 1万

The composer's material — the lit ring around anything you can type into, as @hanzo/gui components.

原始使用文档
文档目录4 节
  1. Composer
  2. Control
  3. Field
  4. What it obeys

@hanzo/composer

The lit ring around anything you can type into, as @hanzo/gui components. The same material on hanzo.ai, hanzo.chat and hanzo.app.

pnpm add @hanzo/composer
import { Composer, Control, Field } from '@hanzo/composer'

<Composer render="form" onSubmit={send} width="100%" maxW={576} mx="auto">
  <XStack items="center" gap="$1.5" p="$1" rounded="$10">{/* your panel */}
    <Field value={draft} onChangeText={setDraft} placeholder="Ask anything" />
    <Control asChild>
      <Voice voice={voice} />
    </Control>
    <Control type="submit" aria-label="Send" fill>
      <ArrowUp size={15} />
    </Control>
  </XStack>
</Composer>

The host wraps the surface's own panel. This package owns the ring, the halo, the round controls and the field's reset; it owns nothing about what typing does. A host writes no CSS against it: every paint is a gui prop reading a @hanzo/design token.

Composer

prop
band1.5The ring's width, px. Also the host's padding: one number, read twice.
halo6How far the halo reaches past the box, px.
control34The round controls' box, px, before --density.

Any gui View prop rides along (render, width, maxW, mx, …). The corner is --radius-composer, with the pill as the floor. The ring rests at .5 and lifts to .8 under a pointer; focus keeps the rest value, because the caret already says where focus is. The halo holds still at .22, blurred 16px.

Control

A circle at the size its Composer names, scaled by --density and floored at 24px (WCAG 2.5.8 AA). size names its own box outside a composer. fill is the send: --primary on --primary-foreground. At rest it is --muted on --text-secondary, and it lifts to --primary under a pointer. A control another package draws wears the shape through asChild.

Field

A gui Input with its chrome off: no border, surface, native appearance or outline, on --text-base, taking the row's spare width down to zero so a long prompt never pushes the controls out of the pill. Any Input prop overrides.

What it obeys

Reads --radius-composer, --density, --text-base, --muted, --text-secondary, --primary, --primary-foreground, --foreground and --muted-foreground from @hanzo/design, each with a fallback.

The sweep is the one stylesheet: a conic angle animates only through @property and @keyframes. It is hoisted once through React's <style>, keyed on the data-slots prism, prism-ring and prism-halo, never a class. Four media queries answer there: prefers-reduced-motion holds the sweep still, prefers-reduced-transparency drops the halo and solidifies the ring, prefers-contrast: more turns the ring into a flat white edge, and forced-colors: active removes both layers for a system-coloured outline.

版本与发布记录

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

版本发布日期距今
0.2.1latest2026/10/3117 天前
0.2.02026/10/021 个月前
0.1.32026/08/163 个月前
0.1.22026/08/163 个月前
0.1.12026/08/163 个月前
0.1.02026/08/163 个月前

关于 @hanzo/composer 的常见问题

@hanzo/composer 是什么?

The composer's material — the lit ring around anything you can type into, as @hanzo/gui components.

如何安装 @hanzo/composer?

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

@hanzo/composer 支持 TypeScript 吗?

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

@hanzo/composer 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@hanzo/composer 可以商用吗?

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

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

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

@hanzo/composer 还在维护吗?

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