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/radio-group.tsx

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

用法

import { Label } from "@/components/ui/label"
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
<RadioGroup defaultValue="option-one">
  <div className="flex items-center gap-3">
    <RadioGroupItem value="option-one" id="option-one" />
    <Label htmlFor="option-one">Option One</Label>
  </div>
  <div className="flex items-center gap-3">
    <RadioGroupItem value="option-two" id="option-two" />
    <Label htmlFor="option-two">Option Two</Label>
  </div>
</RadioGroup>

Composition

Use the following composition to build a RadioGroup:

RadioGroup
├── RadioGroupItem
└── RadioGroupItem

Description

Radio group items with a description using the Field component.

Loading JGuang UI example…

Choice Card

Use FieldLabel to wrap the entire Field for a clickable card-style selection.

Loading JGuang UI example…

Fieldset

Use FieldSet and FieldLegend to group radio items with a label and description.

Loading JGuang UI example…

Disabled

Use the disabled prop on RadioGroupItem to disable individual items.

Loading JGuang UI example…

Invalid

Use aria-invalid on RadioGroupItem and data-invalid on Field to show validation errors.

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 Radio Group documentation.

来源: components/radix/radio-group.mdx

JGuang UI 技术文档。

On this page