Radio A control element for selecting one option from a group of options.

Table of contents


Usage guidelines

When to use
  • Use when only one option may be selected and fewer than five options are available.
  • When more than one option may be selected, use checkboxes.
  • When five or more options are available, use a select.
  • When there are two options, and they are about turning something on or off, or enabling / disabling the same thing, use a switch.
How to use
  • Visually display radio buttons in a vertical (rather than horizontal) list.
  • All text associated with a radio button should be in sentence case.
  • Place radio buttons to the left of their text. The text should be wrapped in a <label> element that is a directly adjacent sibling of the native radio input element.
Accessibility
  • Native keyboard support for radio buttons is carried over to the Resonance radio component.


Attributes

An asterisk next to a value denotes that it is the default value for that attribute. Unless noted otherwise, attributes should be added to the component element directly. Boolean attributes work based on their presence or absence from the component.

<res-component booleanAttribute stringAttribute="parameter">    
  <child-element></child-element>
</res-component>
AttributeTypeDescription
checkedbooleanSet initial state to checked
disabledbooleanSet initial state to disabled

API

NameTypeDataDescription
checkedpropertybooleanGet/set checked state
disabledpropertybooleanGet/set disabled state

Notes

Required DOM

Without these, the component will throw an error on render.

  • <input type="radio"> - (As first child of res-radio)
Supported optional DOM

If added as children, these elements will receive specific styles and/or functionality.

  • <label> - Labelling text (as second child of res-radio)

History

VersionNote
0.12.0Apply new spacing scale. Add min-width to the radio control so that it doesn't get shrunk when the component is too narrow.
0.11.10Focus the label selector so it doesn't get applied inconsistently.
0.11.2Prevent duplicate elements from being created
0.10.0Color update
0.7.0Web component refactor
0.5.0Full refactor! Removed the value and name attributes, as well as the value API. Label positioning now mirrors tag order.
0.3.0Thinner border
0.2.0Cleaner markup, and no longer using classes for .checked and .disabled.
0.1.0Initial build to spec.