JGuang / JGuang UI
Components组件Radix UIRadix UI 组件

复选框

从多个独立选项中选择零项或多项。

中文模式已适配导航、标题、简介、目录与常用章节名称。翻译状态:部分完成;技术正文目前仍为英文。
Loading JGuang UI example…

安装

Command

Manual

Use the JGuang UI Registry URL provided on /systems/jguang-ui#install.

安装以下依赖:

npm install radix-ui

将以下代码复制到你的项目中。

View complete source: components/ui/checkbox.tsx

根据项目配置更新导入路径。

用法

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

Checked State

Use defaultChecked for uncontrolled checkboxes, or checked and onCheckedChange to control the state.

import * as React from "react"

export function Example() {
  const [checked, setChecked] = React.useState(false)

  return <Checkbox checked={checked} onCheckedChange={setChecked} />
}

Invalid State

Set aria-invalid on the checkbox and data-invalid on the field wrapper to show the invalid styles.

Loading JGuang UI example…

Basic

Pair the checkbox with Field and FieldLabel for proper layout and labeling.

Loading JGuang UI example…

Description

Use FieldContent and FieldDescription for helper text.

Loading JGuang UI example…

Disabled

Use the disabled prop to prevent interaction and add the data-disabled attribute to the <Field> component for disabled styles.

Loading JGuang UI example…

Group

Use multiple fields to create a checkbox list.

Loading JGuang UI example…

Table

Loading JGuang UI example…

从右到左布局

To enable RTL support in JGuang UI, see the RTL configuration guide.

Loading JGuang UI example…

API 参考

See the Radix UI documentation for more information.

来源: components/radix/checkbox.mdx

JGuang UI 技术文档。

On this page