Skip to main content

Radio group

Pick one of a few options.

Every hour Every day Every week
<mm-radio-group name="schedule" label="Refresh schedule" value="daily">
<mm-radio value="hourly">Every hour</mm-radio>
<mm-radio value="daily">Every day</mm-radio>
<mm-radio value="weekly">Every week</mm-radio>
</mm-radio-group>

Guidance​

Radio groups pick exactly one of a few options that are all worth seeing at once: a refresh schedule, a sampling strategy, a lineage depth. For more than five options, use a select. The group label works as a legend: it names the group and sits above it in the label style.

Keyboard follows the WAI-ARIA radio group pattern (https://www.w3.org/WAI/ARIA/apg/patterns/radio/): Tab enters the group on the chosen option (or the first), arrow keys move and choose (Left and Right swap in right-to-left), Space chooses the focused option, and Tab leaves the group. orientation only changes the layout.

Form-associated: submits the chosen value under name. required means one must be chosen. The value attribute, or the checked attribute on an mm-radio, is the default the form resets to.

Properties​

PropertyAttributeTypeDefaultDescription
valuevaluestring''The chosen option's value.
orientationorientation'vertical' | 'horizontal''vertical'vertical (default) or horizontal layout. Arrow keys work in both directions either way.
radiosMmRadio[]The options, in order.
labellabelstring''Field label. Rendered above the control unless hide-label, and always the accessible name.
helphelpstring''Help text under the control.
errorerrorstring''Error text: a sentence saying what to fix. Shows the crimson border, an icon and sets aria-invalid.
hideLabelhide-labelbooleanfalseHides the label visually; it stays the accessible name.
optionaloptionalbooleanfalseMarks the field as optional, in words.
namenamestring''Name submitted with the form.
disableddisabledbooleanfalseDisables the control and excludes it from submission.
requiredrequiredbooleanfalseRequires a value before the form submits.
formHTMLFormElement | null
validityValidityState
validationMessagestring
willValidateboolean
isDisabledbooleanTrue when disabled directly or by a disabled ancestor fieldset.

Methods​

MethodDescription
formResetCallback()Restore the initial value when the owning form resets.

Events​

EventDetailDescription
mm-inputCustomEvent<MmValueDetail>When an option is chosen.
mm-changeCustomEvent<MmValueDetail>When an option is chosen.
inputInputEventWhen an option is chosen.
changeEventWhen an option is chosen.

Slots​

SlotDescription
Defaultmm-radio options.

CSS parts​

PartDescription
labelThe group label (legend).
groupThe radiogroup wrapper.
helpThe help line.
errorThe error line.

Examples​

Every state of mm-radio-group in Storybook, with keyboard and screen reader tests.