For AI agents: the complete documentation index is available at https://a3s-lab.github.io/UI/v0.4.0/en/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/UI/v0.4.0/en/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/UI/v0.4.0/en/components/radio-group.md.

Radio Group

Radio Group presents a short set of mutually exclusive options. Use it when every option can be understood without opening another surface and choosing one value is required to continue or configure the current task.

Live preview
View density

Usage

Import Tailwind and the complete A3S style bundle:

@import "tailwindcss";
@import "@a3s-lab/ui/a3s.css";

Give related native radio inputs the same name. Associate every input with a visible label, then give the complete group one accessible name through fieldset and legend or role="radiogroup" and aria-labelledby.

<fieldset class="fieldset">
  <legend data-variant="label">View density</legend>
  <div class="grid gap-3">
    <div class="field" data-orientation="horizontal">
      <input
        class="input"
        type="radio"
        id="density-default"
        name="density"
        value="default"
      />
      <label for="density-default">Default</label>
    </div>
    <div class="field" data-orientation="horizontal">
      <input
        class="input"
        type="radio"
        id="density-compact"
        name="density"
        value="compact"
        checked
      />
      <label for="density-compact">Compact</label>
    </div>
  </div>
</fieldset>

For component-level loading, import the base styles, Radio structure, Field structure, and the A3S visual style in that order. See Installation for CDN and other integrations.

@import "@a3s-lab/ui/base.css";
@import "@a3s-lab/ui/components/radio.css";
@import "@a3s-lab/ui/components/field.css";
@import "@a3s-lab/ui/styles/a3s.css";

Parameters

ParameterValuePurpose
Group<fieldset> or role="radiogroup"Gives the related choices one semantic boundary and name
Root classradio-groupApplies the stable group layout and framework-adapter contract
Root option<input type="radio">Preserves native form, validation, keyboard, and accessibility behavior
classinputApplies Radio structure and visual styles
nameShared stringMakes the options mutually exclusive and submits one value
valueStable stringProvides the submitted application value; do not derive it from visible copy
checkedBoolean attributeMarks the actual initial selection; omit it when the user must make a choice
disabledBoolean attributePrevents selection; explain why the option is unavailable
requiredBoolean attributeRequires one option in the named native group before form submission
aria-invalidtrueExposes a failed validation state after validation has run
aria-describedbyElement IDAssociates constraints, consequences, or recovery guidance

States and variants

Unchecked and checked are the normal interactive states. Arrow keys move selection inside the focused native group; Tab enters and leaves the group as a single stop. Disabled and invalid appearances are meaningful only when the surrounding content explains the constraint or recovery.

With descriptions

The label names the option. Supporting copy explains the effect of choosing it and remains outside the label so assistive technology does not repeat a long description as the option name.

Density with consequences
View density

Balanced spacing for everyday work.

Larger targets and more separation between rows.

More rows on screen with tighter visual spacing.

Choice cards

Use choice cards only when each option needs a title and consequence. data-variant="choice-card" expands the visible option label across the complete field, so the whole card remains one native radio target without invalid nested markup or a second group role. The associated <label> supplies the accessible name; aria-describedby adds the consequence without repeating it as part of that name.

Workspace plan
Workspace plan

For individuals and small teams.

Adds team controls and a shared audit history.

Adds organization policy and managed access.

Fieldset

Prefer fieldset and legend for form questions. The legend supplies the group name, so do not add a nested radiogroup with the same label.

Subscription plan
Subscription plan

Yearly billing saves two monthly payments.

Disabled option

Disable only the unavailable option, preserve the other choices, and put the reason next to the disabled control.

Availability
Execution environment

No compatible device is connected.

Invalid

Do not mark a valid preselected value as an error. Start without an error, validate only after an attempted continuation, focus the first option when the group is still empty, and clear stale error semantics as soon as the user recovers or resets the form.

Required selection
Notification preference

RTL

Set dir="rtl" on the group or an ancestor. Native radio keyboard behavior follows the document direction, while the option order remains the meaningful DOM order.

كثافة العرض
كثافة العرض

تباعد قياسي لمعظم حالات الاستخدام.

مساحة أكبر بين العناصر.

تباعد أدنى للتخطيطات الكثيفة.

Accessibility

  • Give the complete group one concise accessible name. Prefer fieldset and legend in forms; otherwise use role="radiogroup" with aria-labelledby or aria-label.
  • Give every radio a visible label and one stable submitted value. A description belongs in aria-describedby, not inside an excessively long accessible name.
  • Use one shared name for mutually exclusive options. Do not simulate exclusivity with independent buttons or application-only state.
  • Keep native arrow-key behavior. Tab enters the selected radio, arrows move and select, and Tab leaves the group; do not create a separate Tab stop for every option.
  • Do not add role="group" to every option row. The radiogroup or fieldset is the only group boundary.
  • Set disabled on only the unavailable option and keep its reason visible. If all choices are unavailable, disable the owning form action and explain the blocking condition.
  • Show an invalid state only after validation runs. Use required, aria-invalid="true", and aria-describedby to connect a recovery-oriented error; clear stale error attributes and text when a valid option is chosen or the form is reset.
  • Keep the full radio hit target at least 44px on coarse pointers even though the visible indicator remains compact.