Options inside a `ChoiceList`. The wrapping `ChoiceList` component will dictate if the choice renders as radio buttons or checkboxes.
import {
render,
ChoiceList,
Choice,
BlockStack,
InlineStack,
} from '@shopify/checkout-ui-extensions-react';
render('Checkout::Dynamic::Render', () => );
function Extension() {
return (
{
console.log(`onChange event with value: ${value}`);
}}
>
Ship
Pickup
{
console.log(`onChange event with value: ${value}`);
}}
>
Gift message
Gift wrapping
);
}
import {
extend,
ChoiceList,
Choice,
BlockStack,
InlineStack,
} from '@shopify/checkout-ui-extensions';
extend('Checkout::Dynamic::Render', (root) => {
const choiceList = root.createComponent(
ChoiceList,
{
name: 'choice',
value: 'first',
onChange: (value) => {
console.log(`onChange event with value: ${value}`);
},
},
[
root.createComponent(BlockStack, undefined, [
root.createComponent(Choice, {id: 'first'}, 'Ship'),
root.createComponent(Choice, {id: 'second'}, 'Pickup'),
]),
],
);
const multipleChoiceList = root.createComponent(
ChoiceList,
{
name: 'multipleChoice',
value: ['multipleFirst'],
onChange: (value) => {
console.log(`onChange event with value: ${value}`);
},
},
[
root.createComponent(BlockStack, undefined, [
root.createComponent(Choice, {id: 'multipleFirst'}, 'Gift message'),
root.createComponent(Choice, {id: 'multipleSecond'}, 'Gift wrapping'),
]),
],
);
const layout = root.createComponent(InlineStack, undefined, [
choiceList,
multipleChoiceList,
]);
root.appendChild(layout);
});
A unique identifier for the choice.
Whether the choice can be changed.
A label used for buyers using assistive technologies. When set, any `children` supplied to this component will not be announced to screen reader users.