Skip to main content

Choice

Options inside a ChoiceList.

The wrapping ChoiceList component will dictate if the choice renders as radio buttons or checkboxes.

string
required

A unique identifier for the choice.

boolean

Whether the choice can be changed.

string

A label used for buyers using assistive technologies. When set, any children supplied to this component will not be announced to screen reader users.

Was this section helpful?

Basic Choice

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>
);
}

Preview

  • 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.

Was this section helpful?