Skip to main content

Radio

Radio is a radio button component with size variants, custom styling, and optional inline labels. Use the name prop to group radios together.

Import

import { Radio } from "@tosui/react";

Basic Usage

<VStack gap={2} align="flex-start">
<Radio name="fruit" label="Apple" value="apple" />
<Radio name="fruit" label="Banana" value="banana" />
<Radio name="fruit" label="Orange" value="orange" />
</VStack>

Without Label

<Radio name="standalone" aria-label="Option" />

Sizes

<VStack gap={4} align="flex-start">
<Radio size="sm" name="size" label="Small radio" value="sm" />
<Radio size="md" name="size" label="Medium radio (default)" value="md" />
<Radio size="lg" name="size" label="Large radio" value="lg" />
</VStack>

States

<VStack gap={4} align="flex-start">
<Radio name="state1" label="Unchecked" />
<Radio name="state2" label="Checked" defaultChecked />
<Radio name="state3" label="Disabled" disabled />
<Radio name="state4" label="Disabled checked" disabled defaultChecked />
</VStack>

Controlled

Use isChecked and onChange for controlled mode.

function ControlledRadioGroup() {
const [selected, setSelected] = useState("option1");

return (
<VStack gap={2} align="flex-start">
<Radio
name="controlled"
label="Option 1"
value="option1"
isChecked={selected === "option1"}
onChange={() => setSelected("option1")}
/>
<Radio
name="controlled"
label="Option 2"
value="option2"
isChecked={selected === "option2"}
onChange={() => setSelected("option2")}
/>
<Radio
name="controlled"
label="Option 3"
value="option3"
isChecked={selected === "option3"}
onChange={() => setSelected("option3")}
/>
</VStack>
);
}

Radio Group with Label

<VStack gap={2} align="flex-start">
<Box fontWeight="medium">Select your plan:</Box>
<Radio name="plan" label="Free - $0/month" value="free" defaultChecked />
<Radio name="plan" label="Pro - $10/month" value="pro" />
<Radio name="plan" label="Enterprise - Contact us" value="enterprise" />
</VStack>

Props Reference

PropTypeDefaultDescription
size"sm" | "md" | "lg""md"Radio size
labelstring-Optional label text
namestring-Group name (required to link radios)
valuestring-Radio value
disabledbooleanfalseDisable the radio
isCheckedboolean-Controlled checked state
defaultCheckedboolean-Initial checked state (uncontrolled)
onChange(e: ChangeEvent) => void-Change handler

Radio also accepts all native <input type="radio"> attributes.

Accessibility

  • Uses native <input type="radio"> for accessibility
  • Label is associated with the input
  • Use the same name prop to group radios
  • Supports keyboard navigation (arrow keys to switch between options)
  • When no label is provided, use aria-label for accessibility

TypeScript

import { Radio, type RadioSize, type RadioProps } from "@tosui/react";