Skip to main content

Choice

Radio or checkbox group selection.

Usage

<w-choice value="option1" label="Select an option">
<w-slot opt data-value="option1"><button>Option 1</button></w-slot>
<w-slot opt data-value="option2"><button>Option 2</button></w-slot>
<w-slot opt data-value="option3"><button>Option 3</button></w-slot>
</w-choice>

Props

PropTypeDefaultDescription
valuestring""Selected value(s), comma-separated for multiple
multiplebooleanfalseAllow multiple selection
labelstring""Group label
orientation"horizontal" | "vertical""horizontal"Layout direction

Slots

SlotElementDescription
optionButtonSelectable option (use data-value)

Events

EventDetailDescription
change{ value }Selection changed

Keyboard

KeyAction
ArrowRight / ArrowDownNext option
ArrowLeft / ArrowUpPrevious option
SpaceSelect focused option

Examples

Multiple Selection (Checkboxes)

<w-choice multiple value="opt1,opt3" label="Select features">
<w-slot opt data-value="opt1"><button>Feature A</button></w-slot>
<w-slot opt data-value="opt2"><button>Feature B</button></w-slot>
<w-slot opt data-value="opt3"><button>Feature C</button></w-slot>
</w-choice>

Accessibility

  • Single selection: role="radiogroup" with role="radio" options
  • Multiple selection: Options have aria-checked
  • aria-label from label prop
  • Roving tabindex navigation