Radio
One answer out of a few, all in view: two radios or more in a group. The Checkbox's look in a circle, with the same label, description, badge and info icon.
<RadioGroup aria-label="Billing period" defaultValue="monthly"> <Radio value="monthly" description="Billed on the first of the month.">Monthly</Radio> <Radio value="yearly" badge={<Badge color="success" size="md">Save 20%</Badge>}>Yearly</Radio> <Radio value="lifetime">Lifetime</Radio></RadioGroup>Installation
import { Radio, RadioGroup } from "@catalog-developer/components";Usage
import { Radio, RadioGroup } from "@catalog-developer/components";<RadioGroup aria-label="Act-as header" defaultValue="optional">
<Radio value="optional">Optional</Radio>
<Radio value="required">Required</Radio>
</RadioGroup>Anatomy
- 1 — Disc. 14px (sm: 12px). The Checkbox's look in a circle: off, the Input's fill and ring; chosen, the primary button's. Its edge is a shadow, never a border.
- 2 — Dot. White, 6px (sm: 4px), centered, so 4px of disc shows around it at both sizes. It grows in when the radio is chosen.
- 3 — Label. The radio's name, 13px (sm: 12px), 8px after the disc (sm: 6px), the disc centered on its first line. A press on it chooses the radio.
- 4 — Badge and info icon. On the label's line, after it: an md badge and a 12px icon (sm: an sm badge, 11px). The line wraps when it is too long.
- 5 — Description. A line of help 2px under the label, in the secondary text color.
- The group. Its radios stacked 8px apart. Around the disc, 6px more takes the press: a 26px target (sm: 24px).
The colors are the Checkbox's tokens (ds/tokens/checkbox.css, --checkbox-…): the Radio has none of its own. Focus and invalid are the Input's; a disabled disc is at 50%.
Value
Each Radio has a value, and its text is its label. defaultValue names the radio chosen at first, as in the example at the top, and the group keeps the choice itself. With value and onValueChange, as here, the page holds the choice: use it when something else on the screen depends on the answer. With neither, nothing is chosen, and once one is chosen nothing can be cleared again. The group has a name (aria-label here), since nothing visible names it.
const [value, setValue] = useState("round_robin"); <RadioGroup aria-label="Routing strategy" value={value} onValueChange={setValue}> <Radio value="priority_weighted">Priority weighted</Radio> <Radio value="round_robin">Round robin</Radio> <Radio value="least_loaded">Least loaded</Radio></RadioGroup><span className="text-body-2 text-neutral-fg-secondary">Chosen: {value}</span>With a description
description is a line of help under the label, in the secondary text color. The disc stays on the label's first line. The description is tied to the radio with aria-describedby.
<RadioGroup aria-label="Validates" defaultValue="request"> <Radio value="request" description="Validates tool call arguments before the tool runs.">Tool request</Radio> <Radio value="response" description="Validates tool results before they are returned.">Tool response</Radio></RadioGroup>Sizes
One size sets the control and its text together: md, the default, is a 14px disc with a 6px dot and 13px text; sm a 12px disc with a 4px dot and 12px text. The size is set on each Radio, not on the group.
<RadioGroup aria-label="Billing period, medium" defaultValue="monthly"> <Radio value="monthly" size="md" description="Billed on the first of the month.">Monthly</Radio> <Radio value="yearly" size="md">Yearly</Radio></RadioGroup><RadioGroup aria-label="Billing period, small" defaultValue="monthly"> <Radio value="monthly" size="sm" description="Billed on the first of the month.">Monthly</Radio> <Radio value="yearly" size="sm">Yearly</Radio></RadioGroup>Weight
The label is medium by default. regular is for long lists.
<RadioGroup aria-label="Retention" defaultValue="30"> <Radio value="7" weight="regular">7 days</Radio> <Radio value="30" weight="regular">30 days</Radio> <Radio value="90" weight="regular">90 days</Radio></RadioGroup>With a badge or an info icon
badge puts a Badge after the label, on its line: md beside an md label, sm beside an sm one. iconTooltip adds an info icon that explains the option on hover or focus. It takes the text, or the text with the tooltip's settings. A press on the icon never chooses the radio.
<RadioGroup aria-label="Billing period" defaultValue="yearly"> <Radio value="monthly" iconTooltip="Billed on the first of the month.">Monthly</Radio> <Radio value="yearly" badge={<Badge color="success" size="md">Save 20%</Badge>}>Yearly</Radio></RadioGroup>Disabled and read only
disabled on the group turns every radio off: each disc dims to 50% and takes no press, and the chosen one still shows. On one Radio, as in the second group, it turns that option off and leaves the others live; the arrow keys step over it. The label keeps its color, so say why an option is off in its description. readOnly, on the third group, shows the choice and refuses a change, while the radios keep the focus. It has no look of its own (see the open questions).
<RadioGroup aria-label="Act-as header" defaultValue="required" disabled> <Radio value="optional">Optional</Radio> <Radio value="required">Required</Radio></RadioGroup><RadioGroup aria-label="Billing period" defaultValue="monthly"> <Radio value="monthly">Monthly</Radio> <Radio value="yearly" disabled description="Unavailable: this plan is billed by the month.">Yearly</Radio></RadioGroup><RadioGroup aria-label="Body format" defaultValue="object" readOnly> <Radio value="object">Object</Radio> <Radio value="array">Array</Radio></RadioGroup>Invalid, and in a Field
A RadioGroup stands alone until it needs a title or an error. Then a Field gives it both, and it is written two ways today. The first example leaves htmlFor out: the title names the group, the description and the one error are read with it, and while there is an error the Field sets aria-invalid on the group and on every radio in it, which draws the Input's red edge around each disc. The second passes htmlFor={null}, as the catalog's Field controls do: the Field is then plain markup, and the group is named by hand. Which to write is an open question below. Outside a Field, aria-invalid is set on each Radio by hand: an edge with no words, so the rare case.
<Field title="Billing period" description="You can change it later." error="Choose a billing period."> <RadioGroup> <Radio value="monthly">Monthly</Radio> <Radio value="yearly">Yearly</Radio> </RadioGroup></Field> <Field htmlFor={null} title="Billing period" description="You can change it later."> <RadioGroup aria-label="Billing period" defaultValue="monthly"> <Radio value="monthly">Monthly</Radio> <Radio value="yearly">Yearly</Radio> </RadioGroup></Field>Without text
With no children a Radio is the disc alone, for a place that already shows its text: a table row, a list. Name each one with aria-label, since nothing else does.
<RadioGroup aria-label="Default model" defaultValue="primary"> <Radio value="primary" aria-label="Primary" /> <Radio value="fallback" aria-label="Fallback" /></RadioGroup>In a form
name submits the chosen value with a native form, and required stops the form while nothing is chosen. A controlled group, whose form holds its own state, needs neither.
<RadioGroup aria-label="Body format" name="content_format" defaultValue="object" required> <Radio value="object">Object</Radio> <Radio value="array">Array</Radio></RadioGroup>In the dashboard
What radios ask in the dashboard today: 29 groups in 20 files. Each card redraws a real use with the ds Radio and names its file. The dashboard reaches the Radio through components/ui/radio-group.tsx (RadioGroup, RadioGroupItem) and components/ui/radio-option.tsx (RadioOptionGroup, RadioOption), which render this component.
One more kind is not drawn here: the option card (RadioGroupItemCard, seven call sites in three files), a whole Card that is the radio. It lives in the dashboard's wrapper, not in ds/; see the open questions.
Under a Field's title, each option explained
The Field's title asks the question, and each option has a short label with a sentence under it.
components/settings/eventing/custom-webhook-form.tsx
An option that opens a control
The chosen option shows what it needs under its text, indented 22px by hand. The dialog opens on the first option, which keeps every member.
components/settings/role-delete-dialog.tsx
Locked by a scope above
The whole group is disabled when a scope above already requires the answer. A banner above the row says so.
components/agents/agent-form.tsx
The longest list written out: six
What a model quota counts against. No list of radios written out in the dashboard is longer.
components/models/quota-form.tsx
API Reference
RadioGroup
Base UI's RadioGroup with the stack: a <div role="radiogroup">, its radios 8px apart. Every prop passes through, and so does every prop of a <div> (id, data-testid…). It has no orientation.
| Prop | Type | Default | Description |
|---|---|---|---|
value | any | — | The chosen radio's value, held by the page (controlled). Goes with onValueChange. |
defaultValue | any | — | The radio chosen at first, when the group holds the choice itself. Left out, none is chosen. |
onValueChange | (value, eventDetails) => void | — | Runs when another radio is chosen, with its value. |
disabled | boolean | false | Turns every radio off: the discs dim, and take no press. |
readOnly | boolean | false | Shows the choice and refuses a change. The radios keep the focus and their look. |
required | boolean | false | A form can't be submitted while nothing is chosen. Sets aria-required on the group. |
name | string | — | The field's name when a native form is submitted. |
form | string | — | The id of the form that owns the group, when the group sits outside it. |
inputRef | React.Ref<HTMLInputElement> | — | The hidden input a form reads. |
aria-label | string | — | The group's name, when nothing visible names it. A Field's title names it too; so does aria-labelledby. |
className | string | (state) => string | — | Where the group sits (a width, a margin). It stacks its radios itself. |
style | CSSProperties | (state) => CSSProperties | — | As Base UI's. |
render | ReactElement | (props, state) => ReactElement | — | Swaps the <div> for another element. |
children | ReactNode | — | The radios: two or more. |
Radio
Base UI's Radio.Root with our disc and dot, and the text props the Checkbox and the Switch share. With text it renders a <label> around the disc; without, the disc alone. Besides these, every prop of a <span>. className and the other passed props land on the disc, not on the label.
| Prop | Type | Default | Description |
|---|---|---|---|
value | any | — | Required. What the group's value becomes when this radio is chosen. |
children | ReactNode | — | The label, after the disc. A press on it chooses the radio. None for a radio something else names. |
description | ReactNode | — | A line of help under the label. |
weight | "medium" | "regular" | "medium" | The label's weight. Regular is for long lists. |
badge | ReactNode | — | A Badge after the label, on its line: md beside md, sm beside sm. |
iconTooltip | string | TooltipSettings | — | An info icon after the label: the tooltip's text, or the text with its settings (side, align, delay…). |
size | "md" | "sm" | "md" | The disc and its text together: md is 14px with a 6px dot and 13px text, sm 12px with a 4px dot and 12px text. |
disabled | boolean | false | Turns this radio off. The group's disabled turns all of them off. |
readOnly | boolean | false | This radio can't be chosen, and keeps the focus. The group's applies to all. |
required | boolean | false | As the group's, which applies to all. |
aria-invalid | boolean | — | Draws the Input's invalid edge around the disc. A Field's error sets it on every radio inside; outside a Field, set it on each. |
aria-label | string | — | Names a radio that has no text. |
inputRef | React.Ref<HTMLInputElement> | — | The radio's hidden input. |
nativeButton | boolean | false | Base UI's: true when render swaps the disc for a native <button>. |
render | ReactElement | (props, state) => ReactElement | — | Swaps the disc's <span> for another element. |
className | string | (state) => string | — | On the disc. Its size, fill, edge and dot are not set here. |
style | CSSProperties | (state) => CSSProperties | — | On the disc. |
Rules
Open questions
Over a list of choices: htmlFor null, or left out?
OpenBoth are written today, and this page shows both. Left out, a CheckboxGroup or a RadioGroup takes the Field's title, description and error itself. The catalog's Field controls pass null and name the group by hand.
Not a question the other systems have: it is about our own prop.
Do we mark the optional fields, or the required ones?
OpenThe optional ones, with a badge. Required has no mark of its own; a field can pass a Required badge through badge.
Atlassian and Primer mark the required ones with an asterisk after the label; Primer even when every field is required, and Atlassian adds a line saying what the asterisk means. Polaris's required shows an indicator.
Where does a radio list become a Select?
OpenNothing is decided, and no number is ours. The longest list of radios written out in the dashboard today has six options (what a model quota counts against).
Primer puts the limit near six options, and past it points to a select, an action menu or an autocomplete. Polaris's Select page says a select from four options up and a choice list for fewer. Atlassian sends long lists to a select and gives no number.
Two short options side by side?
OpenThe group always stacks and has no orientation. One form (the model rates' "Set my rates" and "Price as another model") passes flex gap-6; the class only widens the gap, so that pair stacks 24px apart today.
Primer is vertical only, for now, and says a column reads faster. Radix has an orientation prop. Base UI, which ours sits on, and Atlassian's group list none.
Does the option card belong in ds?
OpenThe dashboard has a card that is a radio (RadioGroupItemCard: the judges' modes, the SIEM resume choice, compute). It is drawn with the ds Card and this disc, but it lives in components/ui/radio-group.tsx, with no catalog page.
shadcn documents a Choice Card: a radio, its title and its description in one clickable box. The Atlassian, Polaris and Primer pages read for this page show none.
A place for what an option opens
OpenSeveral forms show a control under an option once it is chosen (a role Select, a retry count), each indented 22px by hand to line up with the label.
Polaris's choice list takes content per choice (renderChildren), always shown or only while the choice is selected. The other pages read show no slot for it.
Can a group start empty?
OpenNothing is written down. The component allows it (no defaultValue), and required and the invalid look only make sense then: a group nobody has answered yet.
Atlassian, Polaris and Primer start with one option chosen where they can. Atlassian and Primer add a "none" option when no choice is a real answer. Primer also has a required mark and a validation message.
Read only looks live
OpenreadOnly comes with Base UI. A read-only radio keeps its look, its hover and the pointer, so nothing says the answer is fixed. No screen uses it yet.
Base UI marks each radio with data-readonly and leaves the look to us. Atlassian's and Polaris's radio props and Primer's RadioGroup props, as read, list no read-only.
When to use it
Two named answers or more; on or off is a Switch or a Checkbox
Use a radio group for a question with one answer out of two or more named options, each worth showing. Radios always come as a RadioGroup: there is never a lone radio, which could be chosen and never cleared. When the second option is only "not the first", it is one setting: use a Switch or a Checkbox, with its own label.
From ds/README.md (a RadioGroup is always 2 or more) and ds/components/field.tsx (a setting that is one switch is the Switch, with its own label). Polaris also asks for at least two choices, Primer notes that a radio can't be cleared, and Atlassian sends on and off to a toggle.
One answer is a radio group; several are checkboxes
Use a radio group when choosing one option rules out the others. If two options can be on together, they are checkboxes in a CheckboxGroup.
From Atlassian and Polaris.
A few options in view; a long list in a Select
Use a radio group when the options are few enough to show all at once, one per line, with room to explain each. Use a Select when the list is long.
From Atlassian and Polaris, which send long lists to a select. Where the line sits is an open question.
A radio group holds a value; Tabs switch a view
Use a radio group for a value in a form. Use Tabs for what changes the view in place, such as a split of a list.
From the dashboard's table rules: a split like All, Managed and External is a tab above the table.
Choosing only chooses
The arrow keys choose every radio they pass, so a choice must be cheap to make and to undo. Choosing may show or hide a control under the group. It never opens a dialog, leaves the page or starts work that can't be taken back.
From Primer (choosing a radio must not change the context) and the WAI-ARIA practices (the arrow keys check each radio they reach).
Options and the default
Options that exclude each other, in an order that means something
Every case fits one option and only one. Put the options in an order the reader can follow, not in the order of the alphabet.
From Polaris (no choice overlaps another; an order that makes sense) and Atlassian (no ranges that overlap or skip a value; most likely, simplest or least risky first; not by alphabet, which changes with the language).
Start on the likely answer, and never on the risky one
Where the options differ in risk (access, deletion, cost), the default is the one that changes the least. Where they don't, it is the most likely one.
If "none of these" is a real answer, make it a radio with its own label (None, Off). The user can then choose it, and go back to it.
From Atlassian (one option is the default, the one with the least risk and the least change), Polaris (a default when possible) and Primer (the most likely option). Whether a group may open empty is an open question.
Labels
Name the group
The options are answers, and the group's name is the question. Give it a visible one: a Field's title, a setting row's title, or the sentence right above it in a dialog. A Field's title also names the group for a screen reader. With no Field, set aria-label or aria-labelledby on the group.
From Primer and Polaris (a visible title that says what the choice is) and the WAI-ARIA practices (a radiogroup has a label).
A short label, a sentence under it
A label is a word or a short phrase in sentence case, with no full stop. What it means goes in description, as a sentence.
From design/principles.md (labels are sentence case) and Polaris (no full stop after a label; the help text under it is punctuated).
The text is the Radio's own
Pass the label as children and the help as description. The Radio then sets the gap, the type and the line the disc sits on, and ties the text to the control. Text placed beside a bare disc takes no press. A bare disc is for a table row or a list that already shows the text.
From ds/components/checkbox.tsx: the control and its text are one label.
Errors and disabled
Say what is wrong, and why an option is off
A group has one answer, so it has one error: the Field's error, under the last option (see Invalid, and in a Field). Red edges with no words don't say what is wrong.
Say why an option is off in its description (see Disabled and read only). The arrow keys step over a disabled radio, so the reason has to be in view. When a scope above locks the whole group, disable the group and say who decided, next to it, as the agent form does.
From design/principles.md (validation is inline, under the field; a disabled item stays where a screen reader user can find it). Atlassian and Primer also show a message for an invalid group, and Atlassian validates instead of disabling where the reason must be heard.
Built with the Radio
A row that holds a radio pads 16px
In a card, a row with a radio group in it pads the card inset, 16px, above and below as well as at its sides. A Field with row works this out itself from what it holds.
From the dashboard's rules: a card's row pads 12px around text alone, 16px around a control, and a radio counts.
The Checkbox in a circle, at one size
The Radio reads the Checkbox's tokens and shares its text, so the two always match. Don't give the Radio a color, an edge or a focus ring of its own.
size sets the disc, the dot, the text, the info icon and the gap together: md or sm, nothing set with a class. The dot is 6px at md and 4px at sm, painted at the center of the disc, and never resized or drawn by hand.
If the Radio can't do what a screen needs, add the prop to the Radio and to this page in the same change.
From ds/components/radio.tsx, ds/README.md and the dashboard's rules (build from the shared components).
Accessibility
The keys and attributes below were checked on this page in Chromium. The group is one tab stop, and the arrow keys move inside it. Moving chooses: there is no way to look at an option with the keyboard without choosing it.
| Key | What it does |
|---|---|
| Tab, Shift + Tab | Moves into the group, onto the chosen radio, or onto the first one when none is chosen. Tab again leaves the radios: they are one stop. |
| Down, Right | Moves to the next radio and chooses it. From the last, it goes round to the first. A disabled radio is stepped over. |
| Up, Left | Moves to the previous radio and chooses it. From the first, it goes round to the last. |
| Space | Chooses the focused radio. It only matters when none is chosen yet. |
| Enter, Home, End | Nothing. |
The group is a <div role="radiogroup"> and needs a name. Inside a Field, the title is that name (aria-labelledby), and the Field's description and error describe the group and each radio (aria-describedby). Anywhere else, set aria-label, or aria-labelledby with the id of the text that asks the question.
Each radio is a <span role="radio"> with aria-checked, beside a hidden native radio input. Its label is its name and its description describes it (aria-labelledby, aria-describedby), both set by the Radio. A radio with no text needs aria-label. A badge beside the label is not part of the name, so don't put in a badge what the choice depends on.
States. A disabled radio has aria-disabled, and so has a disabled group, which keeps one tab stop on its chosen radio. required sets aria-required on the group, and readOnly sets aria-readonly on it. A Field's error sets aria-invalid on the group and on each radio.
The info icon is a tab stop of its own, a button named after the label ("Monthly details"), so a group with info icons is more than one stop. A press on it never chooses the radio.
Focus and motion. Focus shows the Input's focus band around the disc. The dot grows in over 150ms, and appears at once under reduced motion.
Not checked with a screen reader. From the attributes above, one should say the group's name on entering it, then each radio's label, its state, its place in the group and its description. The exact words depend on the screen reader.
What others expose
Read on their own pages: shadcn's Radio Group, Base UI's Radio (the primitive ours sits on), Radix's Radio Group, Atlassian's Radio and Primer's RadioGroup. Polaris's radio button and choice list were read in its repository, since its site redirects. "Ask" means it is an open question above, not a decision.
| They expose | Where | Verdict |
|---|---|---|
| A choice card: a radio, a title and a description in one clickable box | shadcn | Ask. The dashboard already has one outside ds: see the open questions. |
FieldSet and FieldLegend around the group | shadcn, Primer (RadioGroup.Label) | Not needed, because a Field's title already names the group. |
| A caption and a validation message as parts of the group, the message as an error or a success | Primer (RadioGroup.Caption, RadioGroup.Validation) | Not needed, because the Field carries the description and the one error for every control, and has no success state. |
orientation, to lay the group out in a row | Radix | Ask: see the open questions. |
loop and dir | Radix | Not needed for loop, because Base UI always goes round. Reading direction was not checked here. |
keepMounted on the indicator | Base UI (Radio.Indicator) | Not needed, because the dot is ours and is drawn only while chosen. Every prop of Base UI's group and radio passes through. |
options: the radios as an array on the group | Atlassian, Polaris (ChoiceList choices) | Not needed, because each Radio is a child with its own description, badge and info icon, which an array would have to copy. |
isInvalid, onInvalid and testId on the group | Atlassian | Not needed, because a Field's error marks every radio in it, and data-testid passes through to the group and to each disc. |
| A label only screen readers get | Polaris (RadioButton labelHidden), Primer (RadioGroup.Label visuallyHidden) | Not needed, because aria-label does it: on a Radio with no children, or on the group. |
| A choice tied to the list's error message | Polaris (ChoiceList describedByError) | Not needed, because a Field's error already describes every radio in it. |
| Content under a choice, always or only while it is chosen | Polaris (ChoiceList renderChildren) | Ask: see the open questions. The dashboard does it by hand in several forms. |
allowMultiple on the same list | Polaris (ChoiceList) | Not needed, because several answers are a CheckboxGroup. |
| A required mark on the group's label | Primer | Ask: nobody has decided whether required fields get a mark. Today the Field marks the other case (optional). See the open question on required fields. |