Choice
Options inside a .
The wrapping component will dictate if the choice renders as radio buttons or checkboxes.
Anchor to choicepropsChoiceProps
- stringrequired
A unique identifier for the choice.
- Anchor to disableddisabledboolean
Whether the choice can be changed.
- Anchor to accessibilityLabelaccessibilityLabelstring
A label used for buyers using assistive technologies. When set, any
children
supplied to this component will not be announced to screen reader users.
ChoiceProps
- id
A unique identifier for the choice.
string
- disabled
Whether the choice can be changed.
boolean
- accessibilityLabel
A label used for buyers using assistive technologies. When set, any `children` supplied to this component will not be announced to screen reader users.
string
export interface ChoiceProps {
/**
* A unique identifier for the choice.
*/
id: string;
/**
* Whether the choice can be changed.
*/
disabled?: boolean;
/**
* A label used for buyers using assistive technologies. When set, any
* `children` supplied to this component will not be announced to screen reader users.
*/
accessibilityLabel?: string;
}
Basic Choice
examples
Basic Choice
React
import { reactExtension, ChoiceList, Choice, BlockStack, InlineStack, } from '@shopify/ui-extensions-react/checkout'; export default reactExtension( 'purchase.checkout.block.render', () => <Extension />, ); function Extension() { return ( <InlineStack> <ChoiceList name="choice" value="first" onChange={(value) => { console.log( `onChange event with value: ${value}`, ); }} > <BlockStack> <Choice id="first">Ship</Choice> <Choice id="second">Pickup</Choice> </BlockStack> </ChoiceList> <ChoiceList name="choiceMultiple" value={['multipleFirst']} onChange={(value) => { console.log( `onChange event with value: ${value}`, ); }} > <BlockStack> <Choice id="multipleFirst"> Gift message </Choice> <Choice id="multipleSecond"> Gift wrapping </Choice> </BlockStack> </ChoiceList> </InlineStack> ); }
JS
import { extension, ChoiceList, Choice, BlockStack, InlineStack, } from '@shopify/ui-extensions/checkout'; export default extension('purchase.checkout.block.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); });
Preview

Anchor to best-practicesBest Practices
Include a title that either tells customers what to do or explains their available options.
Label options clearly based on what the option will do.
Avoid options that contradict each other when you’re allowing for multiple selections.