JGuang / JGuang UI
Components组件Base UIBase UI 组件

Radio Group

A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.

Partially translated: Chinese navigation, titles, descriptions, and common headings. The technical body is currently in English.
Loading JGuang UI example…

Installation

Command

Manual

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

Install the following dependencies:

npm install @base-ui/react

Copy and paste the following code into your project.

View complete source: components/ui/radio-group.tsx

Update the import paths to match your project setup.

Usage

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 RadioGroup to disable all items.

Loading JGuang UI example…

Invalid

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

Loading JGuang UI example…

RTL

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

Loading JGuang UI example…

API Reference

See the Base UI Radio Group documentation.

Source: components/base/radio-group.mdx

Technical documentation for JGuang UI.

On this page