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>
);
}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 | — | Required; identifies the option. |
size | "sm" | "md" | "lg" | "md" | Circle size. |
colorScheme | all 11 schemes | "brand" | Selected hue. |
invalid / disabled / readOnly | boolean | false | State flags — inherited from Field. |
Radio.Group#
| Prop | Type | Default | Description |
|---|---|---|---|
value / defaultValue / onChange | string / string / (value: string) => void | — / "" / — | The selected value. |
name | string | auto | HTML name shared by the set. |
orientation | "horizontal" | "vertical" | "vertical" | Layout. |
colorScheme / disabled | — | — | Shared defaults for every child. |
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.