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.

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.

string | RemoteFragment

Additional content to be revealed when selected.

boolean

Whether the choice can be changed.

string | RemoteFragment

The primary content for a choice. Rendered below <label>.

string | RemoteFragment

The secondary label content for a choice in a group ChoiceList. Ignored in base variant. Rendered on the opposite side to

string | RemoteFragment

The tertiary label content for a choice in a group ChoiceList. Ignored in base variant. Rendered below primaryContent and secondaryContent.

Was this section helpful?

Basic Choice

import {
reactExtension,
Choice,
ChoiceList,
InlineStack,
} from '@shopify/ui-extensions-react/checkout';

export default reactExtension(
'purchase.checkout.block.render',
() => <Extension />,
);

function Extension() {
return (
<InlineStack>
<ChoiceList
name="ship"
value="ship-1"
onChange={(value) => {
console.log(
`onChange event with value: ${value}`,
);
}}
>
<Choice id="ship-1">Ship</Choice>
</ChoiceList>

<ChoiceList
name="gift"
value={['gift-1']}
onChange={(value) => {
console.log(
`onChange event with value: ${value}`,
);
}}
>
<Choice id="multipleFirst">
Gift message
</Choice>
</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?