tuix-radio-button

A radio group rendered from a list of options.

One element renders the whole group: it maps options to one radio each.

Loading the components…
const radio = document.querySelector('tuix-radio-button')
 
radio.options = ['Draft', 'Sent', 'Paid'] // property: it is an array
radio.selectedOption = 'Sent'
 
radio.addEventListener('change', (event) => console.log(event.detail.value))

States

Loading the components…
Loading the components…

error is ignored while the group is disabled.

Label side

Loading the components…

API

Properties

PropertyAttributeTypeDefaultDescription
optionsoptions(string | number)[][]One radio per entry. Property, or JSON in the attribute
selectedOptionselectedoptionstring | number | nullnullThe checked option
labelSidelabelsideCheckboxLabelSiderightleft or right
disableddisabledbooleanfalseBlocks the whole group
errorerrorbooleanfalseRed dots and labels. Ignored while disabled
darkdarkbooleanfalseDark palette

Events

EventDetailWhen
change{ value: string }Another option is picked

The detail carries the option as the DOM reports it, so a numeric option arrives as a string. Typed as CustomEventTuixRadioButton.

The group does not own its selection: the browser checks the radio that was clicked, but selectedOption stays what the application last set, so write the new value back in the handler.

Slots

SlotContent
label-{index}Replaces the label of the option at that index, counting from 0
<tuix-radio-button>
    <tuix-text slot="label-0" size="field_placeholder">Pay now</tuix-text>
    <tuix-text slot="label-1" size="field_placeholder">Pay in 30 days</tuix-text>
</tuix-radio-button>

Each element is one complete group. Its inputs do share the name tuix-radio-button, but they sit in the element's own shadow root, and a native radio group never reaches across two of those, so two tuix-radio-button elements on a page are independent and need no distinct name. The same boundary is why a single group cannot be split over two elements: every option of one group belongs in one options array.

On this page