Radio Group

Radio Group

Single selection from a list of options.

Based on APG Radio Group Pattern.

Demo

Usage

let selected = @resource.signal("all")

@styled_radio.radio_group(
  "notifications",
  [
    @styled_radio.radio_item("all", "All notifications"),
    @styled_radio.radio_item("important", "Important only"),
    @styled_radio.radio_item("none", "None"),
  ],
  selected,
  aria_label="Notification preference",
)

Props

PropTypeDefaultDescription
nameString-Group name
itemsArray[RadioItem]-Radio options
selectedSignal[String]-Selected value
aria_labelString?NoneGroup label
orientationString"vertical"Layout direction
classString?NoneAdditional CSS class

BEM Classes

ClassDescription
.radio-groupGroup container
.radioRadio item wrapper
.radio__controlVisual circle
.radio__indicatorInner dot
.radio__labelLabel text

States

StateDescription
data-selectedSelected option
data-disabledDisabled option

Keyboard

KeyAction
Arrow Down/RightNext option (wraps)
Arrow Up/LeftPrevious option (wraps)
HomeFirst option
EndLast option
SpaceSelect focused