# ChoiceList Use choice lists to present a list of choices where buyers can make a single selection or multiple selections. ### Basic ChoiceList ```js 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); }); ``` ```tsx 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 ); } ``` ## ChoiceListProps ### ChoiceListProps ### name An identifier for the field that is unique within the nearest containing `Form` component. ### value A `string` or `string[]` indicating the ids of selected choices. When a string is set, choices render as radios. When a string array is set, choices render as checkboxes. ### onChange A callback that is run whenever the choice list is changed. This callback is called with a string or array of strings indicating the ids of choices that should now be selected. This component is [controlled](https://reactjs.org/docs/forms.html#controlled-components), so you must store this value in state and reflect it back in the `value` prop. ## Related - [Choice](choice) - [Checkbox](checkox)