ChoiceList

The ChoiceList UI component is used to display a single-choice or multiple-choice list for customers.

Preview

ChoiceList.jpg

Code example

render('Checkout::Dynamic::Render', () => {
return (
<ChoiceList name="choice" type="radio" value="first" onChange={(value) => {
console.log(`onChange event with value: ${value}`);
}}>
<Choice id="first">Ship</Choice>
<Choice id="second">Pickup</Choice>
</ChoiceList>
);
});

ChoiceListProps

tip

Optional properties are marked with a ?. Properties without a ? are required.

name

string

The name of the UI component.


type

radio checkbox

The type of the UI component.


value

T

The IDs of the available choices, which can be a string or an array of strings. If it is a string, the option appears as a radio button; if it is an array, the option appears as a set of checkboxes.


onChange

(value: T) => void

The callback triggered when the choice list is changed.
This callback accepts a string or a string list indicating the IDs of choices that are selected.


Was this article helpful to you?