On this page

InstallationUsageAnatomyValueWith a descriptionSizesWeightWith a badge or an info iconDisabled and read onlyInvalid, and in a FieldWithout textIn a formIn the dashboardAPI ReferenceRadioGroupRadioRulesOpen questionsWhen to use itOptions and the defaultLabelsErrors and disabledBuilt with the RadioAccessibilityWhat others expose

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.

1<RadioGroup aria-label="Billing period" defaultValue="monthly">2  <Radio value="monthly" description="Billed on the first of the month.">Monthly</Radio>3  <Radio value="yearly" badge={<Badge color="success" size="md">Save 20%</Badge>}>Yearly</Radio>4  <Radio value="lifetime">Lifetime</Radio>5</RadioGroup>

Installation

import { Radio, RadioGroup } from "@catalog-dashboard/components";

Usage

import { Radio, RadioGroup } from "@catalog-dashboard/components";
<RadioGroup aria-label="Act-as header" defaultValue="optional">
  <Radio value="optional">Optional</Radio>
  <Radio value="required">Required</Radio>
</RadioGroup>

Anatomy

12345
  1. 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. 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. 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. 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. 5 · Description. A line of help 2px under the label, in the secondary text color.
  6. 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.

1const [value, setValue] = useState("round_robin");2 3<RadioGroup aria-label="Routing strategy" value={value} onValueChange={setValue}>4  <Radio value="priority_weighted">Priority weighted</Radio>5  <Radio value="round_robin">Round robin</Radio>6  <Radio value="least_loaded">Least loaded</Radio>7</RadioGroup>8<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.

1<RadioGroup aria-label="Validates" defaultValue="request">2  <Radio value="request" description="Validates tool call arguments before the tool runs.">Tool request</Radio>3  <Radio value="response" description="Validates tool results before they are returned.">Tool response</Radio>4</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.

1<RadioGroup aria-label="Billing period, medium" defaultValue="monthly">2  <Radio value="monthly" size="md" description="Billed on the first of the month.">Monthly</Radio>3  <Radio value="yearly" size="md">Yearly</Radio>4</RadioGroup>5<RadioGroup aria-label="Billing period, small" defaultValue="monthly">6  <Radio value="monthly" size="sm" description="Billed on the first of the month.">Monthly</Radio>7  <Radio value="yearly" size="sm">Yearly</Radio>8</RadioGroup>

Weight

The label is medium by default. regular is for long lists.

1<RadioGroup aria-label="Retention" defaultValue="30">2  <Radio value="7" weight="regular">7 days</Radio>3  <Radio value="30" weight="regular">30 days</Radio>4  <Radio value="90" weight="regular">90 days</Radio>5</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.

1<RadioGroup aria-label="Billing period" defaultValue="yearly">2  <Radio value="monthly" iconTooltip="Billed on the first of the month.">Monthly</Radio>3  <Radio value="yearly" badge={<Badge color="success" size="md">Save 20%</Badge>}>Yearly</Radio>4</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).

1<RadioGroup aria-label="Act-as header" defaultValue="required" disabled>2  <Radio value="optional">Optional</Radio>3  <Radio value="required">Required</Radio>4</RadioGroup>5<RadioGroup aria-label="Billing period" defaultValue="monthly">6  <Radio value="monthly">Monthly</Radio>7  <Radio value="yearly" disabled description="Unavailable: this plan is billed by the month.">Yearly</Radio>8</RadioGroup>9<RadioGroup aria-label="Body format" defaultValue="object" readOnly>10  <Radio value="object">Object</Radio>11  <Radio value="array">Array</Radio>12</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.

1<Field title="Billing period" description="You can change it later." error="Choose a billing period.">2  <RadioGroup>3    <Radio value="monthly">Monthly</Radio>4    <Radio value="yearly">Yearly</Radio>5  </RadioGroup>6</Field>7 8<Field htmlFor={null} title="Billing period" description="You can change it later.">9  <RadioGroup aria-label="Billing period" defaultValue="monthly">10    <Radio value="monthly">Monthly</Radio>11    <Radio value="yearly">Yearly</Radio>12  </RadioGroup>13</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.

1<RadioGroup aria-label="Default model" defaultValue="primary">2  <Radio value="primary" aria-label="Primary" />3  <Radio value="fallback" aria-label="Fallback" />4</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.

1<RadioGroup aria-label="Body format" name="content_format" defaultValue="object" required>2  <Radio value="object">Object</Radio>3  <Radio value="array">Array</Radio>4</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.

Body format

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.

PropTypeDefaultDescription
valueany—The chosen radio's value, held by the page (controlled). Goes with onValueChange.
defaultValueany—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.
disabledbooleanfalseTurns every radio off: the discs dim, and take no press.
readOnlybooleanfalseShows the choice and refuses a change. The radios keep the focus and their look.
requiredbooleanfalseA form can't be submitted while nothing is chosen. Sets aria-required on the group.
namestring—The field's name when a native form is submitted.
formstring—The id of the form that owns the group, when the group sits outside it.
inputRefReact.Ref<HTMLInputElement>—The hidden input a form reads.
aria-labelstring—The group's name, when nothing visible names it. A Field's title names it too; so does aria-labelledby.
classNamestring | (state) => string—Where the group sits (a width, a margin). It stacks its radios itself.
styleCSSProperties | (state) => CSSProperties—As Base UI's.
renderReactElement | (props, state) => ReactElement—Swaps the <div> for another element.
childrenReactNode—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.

PropTypeDefaultDescription
valueany—Required. What the group's value becomes when this radio is chosen.
childrenReactNode—The label, after the disc. A press on it chooses the radio. None for a radio something else names.
descriptionReactNode—A line of help under the label.
weight"medium" | "regular""medium"The label's weight. Regular is for long lists.
badgeReactNode—A Badge after the label, on its line: md beside md, sm beside sm.
iconTooltipstring | 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.
disabledbooleanfalseTurns this radio off. The group's disabled turns all of them off.
readOnlybooleanfalseThis radio can't be chosen, and keeps the focus. The group's applies to all.
requiredbooleanfalseAs the group's, which applies to all.
aria-invalidboolean—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-labelstring—Names a radio that has no text.
inputRefReact.Ref<HTMLInputElement>—The radio's hidden input.
nativeButtonbooleanfalseBase UI's: true when render swaps the disc for a native <button>.
renderReactElement | (props, state) => ReactElement—Swaps the disc's <span> for another element.
classNamestring | (state) => string—On the disc. Its size, fill, edge and dot are not set here.
styleCSSProperties | (state) => CSSProperties—On the disc.

Rules

Open questions

Over a list of choices: htmlFor null, or left out?

Open
Ours

Both 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.

Other systems

Not a question the other systems have: it is about our own prop.

Do we mark the optional fields, or the required ones?

Open
Ours

The optional ones, with a badge. Required has no mark of its own; a field can pass a Required badge through badge.

Other systems

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?

Open
Ours

Nothing 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).

Other systems

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?

Open
Ours

The 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.

Other systems

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?

Open
Ours

The 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.

Other systems

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

Open
Ours

Several 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.

Other systems

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?

Open
Ours

Nothing 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.

Other systems

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

Open
Ours

readOnly 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.

Other systems

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

DoA question with two answers, each worth reading.
DoOne setting, on or off.
Don’tTwo radios that only say yes and no.

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.

DoThese can be on together: checkboxes.
Don’tRadios force a choice between two things you may want both of.

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.

DoA long list of regions: a Select.
Don’tThe same list as radios pushes the rest of the form away.

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.

DoSwitching what a list shows is Tabs.
Don’tRadios over a table read as a form to fill in.

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

DoEvery case fits one option, from the smallest to the largest.
Don’t30 is in two options, 91 in none, and the larger range comes first.

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).

DoThe role delete dialog opens on the option that keeps every member.
Don’tOne careless Confirm removes people.

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

Body format
DoThe Field's title is the question.
Don’tAnswers with no question in view.

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).

Do
Don’tThe sentence is in the label, with capitals and a full stop.

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

Routing
DoThe card inset on all four sides.
Routing
Don’t8px above and below: the discs crowd the lines.

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.

KeyWhat it does
Tab, Shift + TabMoves 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, RightMoves to the next radio and chooses it. From the last, it goes round to the first. A disabled radio is stepped over.
Up, LeftMoves to the previous radio and chooses it. From the first, it goes round to the last.
SpaceChooses the focused radio. It only matters when none is chosen yet.
Enter, Home, EndNothing.

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 exposeWhereVerdict
A choice card: a radio, a title and a description in one clickable boxshadcnAsk. The dashboard already has one outside ds: see the open questions.
FieldSet and FieldLegend around the groupshadcn, 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 successPrimer (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 rowRadixAsk: see the open questions.
loop and dirRadixNot needed for loop, because Base UI always goes round. Reading direction was not checked here.
keepMounted on the indicatorBase 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 groupAtlassian, 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 groupAtlassianNot 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 getPolaris (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 messagePolaris (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 chosenPolaris (ChoiceList renderChildren)Ask: see the open questions. The dashboard does it by hand in several forms.
allowMultiple on the same listPolaris (ChoiceList)Not needed, because several answers are a CheckboxGroup.
A required mark on the group's labelPrimerAsk: nobody has decided whether required fields get a mark. Today the Field marks the other case (optional). See the open question on required fields.
Catalog
Foundations
  • Overview
  • Tokens
  • Token usage
  • Typography
  • Icons
Atoms
  • Avatar
  • Badge
  • Button
  • Checkbox
  • Color picker
  • Copy button
  • Icon tooltip
  • Inline code
  • Input
  • Hint
  • Kbd
  • Loader
  • Native select
  • Progress bar
  • Progress ring
  • Radio
  • Select
  • Status dot
  • Switch
  • Text link
  • Textarea
  • Tooltip
  • Truncate
Molecules
  • Accordion
  • Activity chart
  • AI elements
  • Alert
  • Button group
  • Card
  • Code block
  • Combobox trigger
  • Command
  • Context switcher
  • Dropdown menu
  • Empty state
  • Field
  • Field group
  • Filter chip
  • Flow
  • Icon picker
  • Metric card
  • Modal
  • Modal confirmation
  • Pagination
  • Popover
  • Scroll area
  • Sidebar
  • Table
  • Tabs
  • Toggle group
LibraryPublished release