Client component
Radio
Single-select options, managed by a group with automatic name wiring.
Selected plan: pro
"use client";
import { useState } from "react";
import { Radio, Text, VStack } from "astralis-ui";
export function RadioDemo() {
const [plan, setPlan] = useState("pro");
return (
<VStack gap="3" alignItems="start">
<Radio.Group value={plan} onChange={setPlan}>
<Radio value="free">Free: 3 projects</Radio>
<Radio value="pro">Pro: unlimited projects</Radio>
<Radio value="team">Team: everything, plus SSO</Radio>
</Radio.Group>
<Text size="xs" color="muted">Selected plan: {plan}</Text>
</VStack>
);
}Label
size
colorScheme
import { Radio } from "astralis-ui";
<Radio>Standard shipping</Radio>
Import#
import { Radio } from "astralis-ui";
// Radio.GroupUsage#
Always wrap radios in Radio.Group: it holds the selected value, shares
one auto-generated name so the browser treats them as a set, and fires
onChange(value) with the plain string.
Orientation, sizes and states#
"use client";
import { Radio, VStack } from "astralis-ui";
export function RadioHorizontal() {
return (
<VStack gap="4" alignItems="start">
<Radio.Group defaultValue="md" orientation="horizontal" colorScheme="teal">
<Radio value="sm" size="sm">Small</Radio>
<Radio value="md">Medium</Radio>
<Radio value="lg" size="lg">Large</Radio>
</Radio.Group>
<Radio.Group defaultValue="a" orientation="horizontal" disabled>
<Radio value="a">Disabled group</Radio>
<Radio value="b">Also disabled</Radio>
</Radio.Group>
</VStack>
);
}Props#
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | number | None | Required; identifies the option. |
size | "sm" | "md" | "lg" | "md" | Circle size. |
colorScheme | all 15 schemes | "brand" | Selected hue. |
invalid / disabled / readOnly | boolean | false | State flags, inherited from [Field](/docs/components/field). |
Radio.Group#
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue / onValueChange | string / string / (value: string) => void | None | Controlled / uncontrolled selection. onChange still fires too, but is deprecated. |
name | string | generated | Name shared by the radios in the set. |
orientation | "horizontal" | "vertical" | "vertical" | Lays the radios out in a row or a column. |
colorScheme | all 15 schemes | None | Hue of every radio in the group; each can still override it. |
disabled | boolean | false | Disables every radio in the group. |
Keyboard#
| Key | Action |
|---|---|
Tab | Into the group: one tab stop (the selected option) |
← ↑ / → ↓ | Move selection between options |
Space | Select the focused option (when none is selected yet) |
Accessibility#
The group renders role="radiogroup" over real <input type="radio">
elements: arrow-key movement between options is native browser behavior.