single-choice-radio
Overview
The single-choice-radio component allows users to make a single selection from a pre-defined set of options.
Basic Example
<var name="animal_type" type="single-choice">
<option key="carnivore">Carnivore</option>
<option key="herbivore">Herbivore</option>
<option key="omnivore">Omnivore</option>
</var>
<single-choice-radio label="Options" bind="animal_type" />
Standard Attributes
bind
bindbindlabel
labellabelrequired
requiredrequiredAdvanced Attributes
align-content
align-contentalign-contentalign-label
align-labelalign-labeldisabled
disableddisabledid
ididlabel-case
label-caselabel-caselabel-color
label-colorlabel-colormode
modeOptional
Type: row | column
Default: column
Configure the layout of the list of options. row lists options horizontally; column lists options vertically.
on-change
on-changeon-changeradio-position
radio-positionOptional
Type: left | right
Default: left
Specify where the radio button is positioned in the component (relative to the option label).
<columns>
<column>
<info>radio-position="left"</info>
<single-choice-radio radio-position="left" bind="favorite_color_single" label="Favorite color" />
</column>
<column>
<info>radio-position="right"</info>
<single-choice-radio radio-position="right" bind="favorite_color_single" label="Favorite color" />
</column>
</columns>
show-if and hide-if
show-ifhide-ifshow-if and hide-ifComponent Methods
The following component methods are available when an id is assigned to the component and component.singleChoiceRadio({id:'my-id'}) is called from JS/TS:
scrollIntoView
scrollIntoViewProgrammatically scroll until the single-choice-radio component is visible in the view.
selectItem
selectItemProgrammatically select an item by its label.
<var name="favorite_color" type="single-choice">
<option key="green">Green</option>
<option key="red">Red</option>
<option key="yellow">Yellow</option>
</var>
<single-choice-radio id="my-radio" bind="favorite_color" label="Favorite Color" />
function select() {
component.singleChoiceRadio({id: 'my-radio'}).selectItem('Yellow');
}selectItemByIndex
selectItemByIndexProgrammatically select an item by its index. Note: Indexes begin at 1.
<var name="favorite_color" type="single-choice">
<option key="green">Green</option>
<option key="red">Red</option>
<option key="yellow">Yellow</option>
</var>
<single-choice-radio id="my-radio" bind="favorite_color" label="Favorite Color" />
function select() {
component.singleChoiceRadio({id: 'my-radio'}).selectItemByIndex(2);
// Selects "Red"
}Last updated
