Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Buttons

  • Button
  • ShimmerButton
  • InteractiveHoverButton
  • RainbowButton
  • PulsatingButton
  • RippleButton
  • ButtonGroup
  • SocialButton

Basic Inputs

  • Input
  • Textarea
  • CellEditor
  • Select
  • Checkbox
  • CheckboxGroup
  • Radio
  • Switch
  • Toggle
  • Segmented
  • Slider
  • NumberField
  • ElasticSlider

Advanced Inputs

  • MathTextarea
  • QuestionEditor
  • QuestionAnswer
  • MathField
  • SecretField
  • PasswordGenerator
  • Combobox
  • RemoteSelect
  • Listbox
  • Mentions
  • InputOTP
  • Rating
  • Upload
  • RegionSelect
  • ImageCropper
  • ScopeMatrix
  • Transfer
  • Cascader
  • TreeSelect
  • RegionCascader
  • CountrySelect
  • MarkdownEditor
  • Novel editor
  • RichTextEditor
  • CodeEditor
  • IssueReporter
  • ColorPicker
  • ColorField
  • ColorSwatchPicker
  • Choicebox
  • EmojiPicker
  • VoiceRecord
  • IconPicker
  • InspectorPanel

Date and Time

  • Calendar
  • DatePicker
  • DateTimePicker
  • DateRangePicker
  • TimePicker
  • TimeField

Form Frameworks

  • Form
  • ModalForm / DrawerForm
  • ProForm
  • StepsForm
  • LoginForm
  • AuthPanel
  • ClickCaptcha
  • Label
  • Field
  • SearchForm

Radio

radio

Selects one mutually exclusive value from an accessible radio group.

Usage

Basic usage

RadioGroup packages multiple Radio, single selections are mutually exclusive, and the default is vertical arrangement.

tsx
<RadioGroup defaultValue="b" aria-label="options">
  <Radio value="a" label="Option 1" />
  <Radio value="b" label="Option 2" />
  <Radio value="c" label="Option 3" />
</RadioGroup>

Horizontal arrangement

Set orientation="horizontal" to arrange the options horizontally.

tsx
<RadioGroup orientation="horizontal" defaultValue="m" aria-label="Gender">
  <Radio value="m" label="Male" />
  <Radio value="f" label="Female" />
</RadioGroup>

Disabled

A single Radio plus disabled disables one item; the entire group disabled disables all.

tsx
<RadioGroup defaultValue="a" aria-label="Package">
  <Radio value="a" label="Standard" />
  <Radio value="b" label="Professional (not available yet)" disabled />
  <Radio value="c" label="Flagship" />
</RadioGroup>

With Field verification

Package into Field to get labels and error prompts, and the check state will be transmitted to the circle stroke.

Please select a package
tsx
<Field label="Package" error="Please select a package" className="w-72">
  <RadioGroup defaultValue="">
    <Radio value="basic" label="Basic Edition" />
    <Radio value="plus" label="Enhanced Version" />
  </RadioGroup>
</Field>

When to use

Use Radio when exactly one choice must be selected from a small set (typically two to six) and every option should remain visible. Use Select when a larger set should collapse or support search, CheckboxGroup when several choices may coexist, or Segmented for two or three compact horizontal choices with a sliding indicator.

Import

ts
import { RadioGroup, Radio } from "@hulianui/ui"

Props

RadioGroup

NameTypeDefaultDescription
valuestring-Controlled selected value.
defaultValuestring-Initial selected value when uncontrolled.
disabledbooleanfalseDisables the entire group.
requiredboolean-Marks the native form control as required.
namestring-Native form name
orientation"vertical"|"horizontal""vertical"Controls layout only.
classNamestring--
aria-labelstring-Provided when no title is visible

Radio

NameTypeDefaultDescription
value *string-Required value identifying the option.
disabledbooleanfalseDisables this option.
idstring--
size"sm" | "md""md"Size step; the ring and its inner dot scale together. md is 20px/10px/text-sm, sm is 16px/8px/text-xs.
classNamestring-Applied to Radio.Root (the ring); it cannot reach the label text.
labelClassNamestring-Applied to the label <span> for font size and color.
aria-labelstring-Accessible name. Required when label is omitted or contains only visual content such as an icon.
aria-labelledbystring-ID of an existing element used as the accessible name; use instead of aria-label.
aria-describedbystring-ID of supplementary descriptive text for the option.

Events

RadioGroup

EventTypeDescription
onValueChange(value: string) => voidCalled when selection changes.

Slots

RadioGroup

SlotTypeDescription
childrenReactNodeRadio items in the group.

Radio

SlotTypeDescription
labelReactNodeOptional clickable inline label with native <label> association.
childrenReactNodeEquivalent to label: <Radio value="1">Approved</Radio>. When both are given, label wins.

Example

tsx
<RadioGroup defaultValue="b" aria-label="Options">
  <Radio value="a" label="Option one" />
  <Radio value="b" label="Option two" />
  <Radio value="c" label="Option three (disabled)" disabled />
</RadioGroup>

Horizontal and controlled:

tsx
const [value, setValue] = useState("standard");
<RadioGroup value={value} onValueChange={setValue} orientation="horizontal" aria-label="Plan">
  <Radio value="standard" label="Standard" />
  <Radio value="pro" label="Pro" />
</RadioGroup>

Usage guidelines

  • RadioGroup owns selection; individual Radio items do not expose a separate checked state.
  • Controlled usage requires value and onValueChange. Use defaultValue only for uncontrolled initial state; do not mix the two patterns.
  • Give a group without a visible heading an aria-label so screen readers can identify its purpose.
  • A Radio without a textual label must provide aria-label or aria-labelledby. This includes icon cards and custom layouts; otherwise assistive technology announces only “radio button” without identifying the choice.
  • Wrapping the Radio in your own <label> does work, so there is no need to forward onClick by hand. The Root renders as <span role="radio">, which is not a labelable element, so the DOM makes implicit association look broken, but Base UI keeps a visually hidden native input inside to carry activation. Use this when the typography is too specific for size plus labelClassName.
  • Do not add <label htmlFor> pointing at the Root id while also wrapping: an explicit htmlFor overrides the implicit association, and having both means clicking the text does nothing at all.
  • Inside a Field, each Radio is named by its own label; the Field label names the whole RadioGroup (role=radiogroup), and description / error still reach every item.

Related

Input · Textarea · Select · Checkbox · CheckboxGroup · Switch

Playground

<RadioGroup orientation="vertical" defaultValue="standard">
  <Radio value="standard" label="Standard" />
  <Radio value="pro" label="Professional" />
</RadioGroup>
PreviousCheckboxGroupFormsNextSwitch

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Example
    • Usage guidelines
    • Related
  • Playground