Component

Checkbox

安装 Installation

npx timkit add checkbox --yes --framework react

用法 Usage

import { Checkbox } from "@/components/ui/checkbox"

className 与 variant、size 可以一起用。字段以 timkit agent inspect checkbox --json 的 props 为准。

示例

Examples

一次看一个示例。左侧按名称筛选,预览里可切换源码和框架。

20 / 20

Checkbox · With label · 01

Loading preview...

结构化 API

Structured API

与 UCS schema 对齐的 props、逻辑机与多框架运行时。

Component

checkbox

Logic

zag / checkbox

Runtime Frameworks

ReactVueWeappHTML

Supported Platforms

WebWeChat Mini Program

Configuration

PropTypeDefaultDescription
logic.provider*
enum (zag | native | none)
zagState and interaction provider used by this component.
logic.machine
string
checkboxUnderlying state machine identifier when provider is zag.
platforms*
array
Web, WeChat Mini ProgramPlatforms officially supported by this schema.
frameworks*
array
React, Vue, Weapp, HTMLFramework demos/code currently available in registry files.
dependencies
array
@timui/core, @zag-js/reactRuntime package dependencies required by this registry item.
optionalPeerDependencies
array
-Optional peer dependencies used by this registry item.
registryDependencies
array
use-machineDependent Timkit registry components/hook entries.

Props

PropTypeDefaultDescription
checked
boolean
-The controlled checked state. The value indeterminate is announced as mixed.
disabled
boolean
falseWhether the checkbox is disabled.
required
boolean
falseWhen true, the checkbox is announced as required.
readOnly
boolean
falseWhen true, checked changes are ignored.

Events

PropTypeDefaultDescription
onCheckedChange
event
-Callback called when checked state changes.

TypeScript

来自 TypeScript 导出。

PropTypeDefaultDescription
id
string
-Input behavior configuration for id.
defaultChecked
CheckboxCheckedState
-The default checked state of the component when initially rendered.
name
string
-The name of the component, used when submitting an HTML form.
value
string
-The controlled value of the component.
modelValue
CheckboxCheckedState | null
-The controlled value bound via `v-model` (Vue specific).

Slots

PropTypeDefaultDescription
default
slot
-The content of the checkbox

Parts

PropTypeDefaultDescription
root*
root
-The checkbox container
indicator
part
-The visual indicator of the checked state
This API reference is generated from `/packages/core` component schemas to keep React/Vue/Weapp docs consistent.

该组件尚无扩展说明文档。

键盘与焦点

Keyboard

跨 React、Vue 与小程序共享的交互与可读名称约定。

  • Space toggles the checkbox.
  • The checkbox is in the tab order unless it is disabled.
  • On React and Vue, an omitted name is Checkbox.
  • A passed aria-label names the checkbox.
  • A checked box is visible as Checked.
  • An indeterminate box is visible as Mixed.
  • An unchecked box has no check status.
  • In static HTML, the visible control is not a second tab stop.
  • On the mini program, an empty description is left off.
  • On the mini program, the check mark is hidden from the name.

行为契约

Contract

props、默认值和运行时状态。

  • When read-only, clicks and Space do not change the checked state.
  • On the mini program, a later checked value still applies.
  • A checked value of indeterminate is announced as mixed.
  • A required checkbox is announced as required.