v0.1.0-alpha
官网Home
docs/reference/public-api
参考 · Surface mapReference · Surface map

公开 API 参考Public API

快速判断一个能力应该从 ui 顶层还是子命名空间获取。Tell at a glance whether a capability lives at the ui top level or in a sub-namespace.

预计阅读 6 分钟6 min read

src/ui/ui.zig 就是完整的公开 API:应用只使用 ui.* 与 ui.<group>.*,破坏其中任何一个名字都算 API break。src/ui/ui.zig is the entire public API: apps use only ui.* and ui.<group>.*, and breaking any name in either counts as an API break.

imports.zig
const ui = @import("ui");
const zenit_app = @import("zenit_app");

// Tier 1: straight off ui
const title = try ui.text(cx, "Hello", .{});

// Tier 2: through the group
const theme = &ui.theme.dark;
const Router = ui.fx.Router;

Tier 1 · ui.X

每个应用都会用到的顶层名字,按用途分组。前五组覆盖大多数界面文件;最后一组面向自定义绘制与框架宿主。The top-level names every app reaches for, grouped by purpose. The first five groups cover most UI files; the last one is for custom drawing and framework hosts.

Runtime
上下文、节点与生命周期Context, nodes and lifetime
Cx · Node · Scope · Style · BoxStyle · HandlerRef
Builders
节点构造Node constructors
box · hstack · vstack · text · textFmt · image · imageTint · svg · svgTint · icon · iconTint · spacer · clickable · grid · animateNode
Styled
主题安全构造与样式系统Theme-safe builders and styling
boxStyled · hstackStyled · vstackStyled · textStyled · iconStyled · iconTintStyled · recipe · ConditionalStyle · arb · ThemeTokens · ColorScheme
Layout
布局值类型Layout value types
Sizing · Size · Point · Padding · Margin · Border · Outline · Direction · FlexWrap · AlignItems · JustifyContent · ComputedRect · GridStyle
Paint
颜色与绘制效果Color and paint effects
Color · BlendMode · CornerRadius · CornerRadii · Shadow · InsetShadow · Gradient · GradientStop · MultiGradient · GradientDirection · GlassParams · GlassSurface
Text
文本属性与折行产物Text props and layout output
TextProps · TextStyle · TextWrap · TextAlign · TextLayout · LineInfo · textAlignLineOffset · TextInputClient · TextInputSelection
Media & cursor
图像、图标与光标Images, icons and cursors
ImageProps · IconProps · SvgAsset · CursorShape · CursorRegion · CursorToken · CustomCursorDesc
Reactive
响应式基础(完整面在 ui.reactive)Reactive essentials (full set in ui.reactive)
Signal · Memo · createEffect · createMemo
Control flow
条件与列表(也在 ui.control_flow)Conditionals and lists (also ui.control_flow)
Show · For · Match
A11y
无障碍属性Accessibility properties
A11yRole · A11yProps · A11yOrientation · A11ySortDirection · A11yRect · A11yValueRange
Components
受控 / 非受控 propControlled / uncontrolled props
ControlledProp
Advanced
自定义绘制、布局回调与分片任务Custom drawing, layout callbacks and sliced tasks
DisplayItem · DrawContext · BulkQuad · AfterLayoutFn · AfterLayoutResult · max_after_layout_rounds · PointerDownFocus · Task · WorkKey · frame

Tier 2 · ui.<group>.X

按关注点分组。需要超出基础能力时再使用。Grouped by concern. Reach for these when you need more than the basics.

命名空间Namespace能力Contents
ui.widgets完整组件库:Button、Input、Modal、Tabs、VirtualList、Calendar、Notifier、FormOf…The component library: Button, Input, Modal, Tabs, VirtualList, Calendar, Notifier, FormOf…
ui.fx动画(Tween、Spring、Timeline)、物理、Transition / SnapshotTransition、RouterAnimation (Tween, Spring, Timeline), physics, Transition / SnapshotTransition, Router
ui.events完整 Event 与 EventResult,键鼠、滚轮、拖放、IME(ImePreeditEvent / ImeCommitEvent)payloadThe full Event and EventResult plus key, mouse, scroll, drag and IME (ImePreeditEvent / ImeCommitEvent) payloads
ui.hooksuseHover、useFocusRing、useHoverHighlight、useAnimatedBackground、onMount / onCleanupuseHover, useFocusRing, useHoverHighlight, useAnimatedBackground, onMount / onCleanup
ui.reactive完整响应式系统:Scope、Context、StoreOf、SignalOwner、eqlValueThe full reactive system: Scope, Context, StoreOf, SignalOwner, eqlValue
ui.control_flowShow / For / Match 及其选项类型Show / For / Match and their option types
ui.focusFocusManager、FocusScopeConfig、tab orderFocusManager, FocusScopeConfig, tab order
ui.actionsAction、KeyBinding、CommandBinding、ActionDispatcherAction, KeyBinding, CommandBinding, ActionDispatcher
ui.themeThemeTokens、ColorTokens 与内置 light / dark / high_contrastThemeTokens, ColorTokens and the built-in light / dark / high_contrast
ui.icons所选 provider 的完整图标目录(get、all)The selected provider’s full icon catalog (get, all)
ui.system_icons与 provider 无关的语义图标角色Provider-neutral semantic icon roles
ui.assetsSVG Asset 类型与 common 兼容图标The SVG Asset type and legacy common icons
ui.interactionRangeHoverRegistry、drag 等交互原语Interaction primitives such as RangeHoverRegistry and drag
ui.select_headlessSelect 的 headless 状态机(step、commitSelection)Headless Select state machine (step, commitSelection)
ui.gesture手势识别与仲裁(Recognizer、GestureArena)Gesture recognition and arbitration (Recognizer, GestureArena)
ui.hit / ui.path命中测试(HitQuery、HitBehavior…)与路径几何(PathCommand、Transform2D…)Hit testing (HitQuery, HitBehavior…) and path geometry (PathCommand, Transform2D…)
ui.platform_services剪贴板与文件对话框,参数为 cx.system_sdkClipboard and file dialogs, taking cx.system_sdk
ui.text_shaping字体解析与测量钩子(setShapeFontResolver…)Font resolution and measurement hooks (setShapeFontResolver…)
ui.consoleper-Cx 日志:Console、ScopedConsole、Level、Config、SnapshotPer-Cx logging: Console, ScopedConsole, Level, Config, Snapshot
ui.devtoolsoverlay(窗口内检查)、mountPanel(独立面板)、trace、source_linkoverlay (in-window inspector), mountPanel (standalone panel), trace, source_link

组件的 props 与结果类型见组件站;图标清单见 Icon Gallery。ui.a11y 只用于平台运行时接线,应用作者不需要它——组件的无障碍信息写在节点的 A11yProps 上。Component props and result types are on the component site; the icon list is in the Icon Gallery. ui.a11y exists only for platform runtime wiring and isn’t for app authors — component accessibility lives in a node’s A11yProps.

zenit_app

zenit_app.App 是单窗口运行时助手,负责平台 / GPU / 字体初始化与事件循环;zenit_app.MultiWindowApp 管理多个独立原生窗口(上限 16 个,超出返回 error.TooManyWindows)。同一模块还导出 WindowConfig、MultiWindowConfig、FontConfig 与 ResourcePath。高级宿主可以使用更低层的接口,但普通应用应从这里开始。zenit_app.App is the single-window runtime helper — platform, GPU and font setup plus the event loop; zenit_app.MultiWindowApp manages several independent native windows (at most 16; beyond that you get error.TooManyWindows). The module also exports WindowConfig, MultiWindowConfig, FontConfig and ResourcePath. Advanced hosts can go lower, but ordinary apps should start here.

边界Boundary

zenit · 双授权Dual-licensed开源项目可按 GPL-3.0-only 免费使用;闭源或商业产品需要商业授权。Free for open-source projects under GPL-3.0-only; closed-source or commercial products need a commercial license.可联系作者:Contact the author: zongyi.xzy#gmail.com(# 换成 @) (replace # with @)zenit 5f9add5+wip 2026-09-30