Radio Group
A set of radio options, all visible at once, where exactly one can be chosen.
<arc-radio-group>Overview
RadioGroup shows every option up front and lets the reader pick exactly one. Select hides the options in a dropdown. RadioGroup suits two to six options that people compare before choosing, like pricing tiers, shipping methods or account types.
Each option is an <arc-radio> with a value. The group reads each option's text content as its label and renders its own copy, so markup inside an <arc-radio> comes out as plain text.
The whole group is one Tab stop. Any arrow key moves to the next or previous option and selects it, wrapping at either end, and Space selects the focused option. Each selection fires arc-change with the new value.
Add disabled to one <arc-radio> to rule out that option and leave the rest live. Like a disabled native radio, it's dimmed and announced as disabled, the arrow keys skip it, and a click or Space doesn't select it.
orientation is vertical by default, which suits longer labels. horizontal puts short labels in a row, like sizes S, M, L and XL. With a name, the selected value submits with native forms.
Guidelines
Do
- Select the most common or recommended option by default, unless the choice is optional
- Put a visible label or heading above the group so readers know what they're choosing
- Group related radio groups under one fieldset or section heading
Don't
- Don't use it for more than six or seven options. Use Select or Combobox
- Don't put radio groups and checkboxes in the same row. They select in different ways
- Don't use `horizontal` with long labels. They wrap badly on small screens
Features
- `radiogroup` role, with `role="radio"` and `aria-checked` on each option
- `disabled` on the group blocks clicks and keys and drops it to 50% opacity
- `disabled` on one `<arc-radio>` gives that option `aria-disabled="true"` and 50% opacity, and takes it out of selection and arrow-key order
- The group's `aria-label` is its `name` attribute
Preview
Usage
Its events and state need JavaScript, so use the Web Component or a framework wrapper for those.
<script type="module" src="@arclux/arc-ui"></script>
<!-- Vertical (default) -->
<arc-radio-group name="plan" value="starter">
<arc-radio value="starter">Starter — Free for individuals</arc-radio>
<arc-radio value="pro">Pro — $12/mo for teams</arc-radio>
<arc-radio value="enterprise">Enterprise — Custom pricing</arc-radio>
</arc-radio-group>
<!-- Horizontal layout -->
<arc-radio-group name="size" value="md" orientation="horizontal">
<arc-radio value="sm">Small</arc-radio>
<arc-radio value="md">Medium</arc-radio>
<arc-radio value="lg">Large</arc-radio>
<arc-radio value="xl">X-Large</arc-radio>
</arc-radio-group>
<script>
document.querySelector('arc-radio-group')
.addEventListener('arc-change', (e) => {
console.log('Selected:', e.detail.value);
});
</script>import { RadioGroup, Radio } from '@arclux/arc-ui-react';
import { useState } from 'react';
function PricingPlan() {
const [plan, setPlan] = useState('starter');
return (
<RadioGroup
name="plan"
value={plan}
onArcChange={(e) => setPlan(e.detail.value)}
>
<Radio value="starter">Starter — Free for individuals</Radio>
<Radio value="pro">Pro — $12/mo for teams</Radio>
<Radio value="enterprise">Enterprise — Custom pricing</Radio>
</RadioGroup>
);
}
function SizeSelector() {
return (
<RadioGroup name="size" value="md" orientation="horizontal">
<Radio value="sm">Small</Radio>
<Radio value="md">Medium</Radio>
<Radio value="lg">Large</Radio>
<Radio value="xl">X-Large</Radio>
</RadioGroup>
);
}<script setup>
import { RadioGroup, Radio } from '@arclux/arc-ui-vue';
import { ref } from 'vue';
const plan = ref('starter');
</script>
<template>
<RadioGroup name="plan" :value="plan" @arc-change="plan = $event.detail.value">
<Radio value="starter">Starter — Free for individuals</Radio>
<Radio value="pro">Pro — $12/mo for teams</Radio>
<Radio value="enterprise">Enterprise — Custom pricing</Radio>
</RadioGroup>
</template><script>
import { RadioGroup, Radio } from '@arclux/arc-ui-svelte';
let theme = 'dark';
</script>
<RadioGroup name="theme" value={theme} orientation="horizontal"
on:arc-change={(e) => theme = e.detail.value}>
<Radio value="light">Light</Radio>
<Radio value="dark">Dark</Radio>
<Radio value="auto">System</Radio>
</RadioGroup>import { Component } from '@angular/core';
import { RadioGroup, Radio } from '@arclux/arc-ui-angular';
@Component({
imports: [RadioGroup, Radio],
template: `
<arc-radio-group name="plan" [value]="plan" (arc-change)="plan = $event.detail.value">
<arc-radio value="starter">Starter — Free for individuals</arc-radio>
<arc-radio value="pro">Pro — $12/mo for teams</arc-radio>
<arc-radio value="enterprise">Enterprise — Custom pricing</arc-radio>
</arc-radio-group>
`,
})
export class PricingComponent {
plan = 'starter';
}import { RadioGroup, Radio } from '@arclux/arc-ui-solid';
import { createSignal } from 'solid-js';
function ShippingMethod() {
const [method, setMethod] = createSignal('standard');
return (
<RadioGroup name="shipping" value={method()}
onArcChange={(e) => setMethod(e.detail.value)}>
<Radio value="standard">Standard — 5-7 business days</Radio>
<Radio value="express">Express — 2-3 business days</Radio>
<Radio value="overnight">Overnight — Next business day</Radio>
</RadioGroup>
);
}import { RadioGroup, Radio } from '@arclux/arc-ui-preact';
import { useState } from 'preact/hooks';
function NotificationPreference() {
const [pref, setPref] = useState('email');
return (
<RadioGroup name="notify" value={pref}
onArcChange={(e) => setPref(e.detail.value)}>
<Radio value="email">Email notifications</Radio>
<Radio value="sms">SMS notifications</Radio>
<Radio value="push">Push notifications</Radio>
<Radio value="none">No notifications</Radio>
</RadioGroup>
);
}<!-- arc-radio-group is interactive — requires JS -->
<arc-radio-group></arc-radio-group><!-- arc-radio-group is interactive — requires JS -->
<arc-radio-group></arc-radio-group>API
valuestring''- The currently selected value. Must match one of the child arc-radio value attributes. Setting this property programmatically updates the visual selection and the internal aria-checked state.
namestring''- The form field name submitted with the selected value. Required for native form integration: without it, the selection will not appear in FormData.
disabledbooleanfalse- When true, disables all options in the group. The component becomes non-interactive: arrow-key navigation is suppressed, click events are ignored, and the group is excluded from the Tab order.
orientation'vertical' | 'horizontal''vertical'- Controls the layout direction of the radio options. Vertical stacks options top-to-bottom and maps Arrow Up/Down to navigation. Horizontal places options in a row and maps Arrow Left/Right.
size'sm' | 'md' | 'lg''md'- Controls the radio button and label size.
formAssociatedbooleantruepropertiesobject{ // flag(), unlike `disabled`. The exclusion in props.js is specifically // about form-associated *platform* semantics: a `disabled` content // attribute that is merely present makes the element actually disabled // per the HTML spec, and formDisabledCallback assigns the property back, // so no converter can win. Neither of these is platform-mapped: // `required` is enforced by _computeValidity() below and `readonly` by // each component's own interaction handlers, so the stock converter buys // nothing here and costs the usual bug: `required="false"` read as true, // blocking submission of a form the author meant to leave optional. // Finding #48's shape, across all 26 form controls at once. required: flag(false), readonly: flag(false), }- Lit merges static properties up the prototype chain, so every consumer
gets these without declaring them.
requiredparticipates in constraint validation below;readonlyreflects for styling and is enforced by each component's interaction handlers (the mixin can't know which gestures mutate state). autoValidatesbooleantrue- Components that run their own constraint-validation logic (pattern checks, range checks) opt out of the automatic required sync by overriding this to false, and own the whole validity flag set instead.
formvalidityvalidationMessagerequiredbooleanfalsereadonlybooleanfalse
Methods
checkValidity()boolean- Whether the control currently satisfies its constraints, per the native
constraint-validation API. Fires
invalidon the element when it does not, and reports nothing to the user. reportValidity()boolean- As checkValidity(), but also shows the browser's validation message against the control when it fails.
Events
arc-changedetail:{ value: string }- Fired when the selected radio value changes
Radio
<arc-radio>One option in a RadioGroup. Its `value` is what the group submits, and its text content is the label.
labelvaluestring''- The value submitted when this option is selected. Must be unique within the parent RadioGroup.
disabledbooleanfalse- When true, the option is dimmed and announced as disabled, the arrow keys skip it, it is never the group's Tab stop, and a click or Space does not select it. Setting it does not clear a group
valuethat already names this option.