Choice list
The choice list component presents multiple options for single or multiple selections. Use it when merchants need to choose from a defined set of options, such as filtering results or collecting preferences.
The component supports both single selection (radio button behavior) and multiple selection (checkbox behavior) modes. It includes configurable labels, help text, and validation. For compact dropdown selection with four or more options, use select.
Anchor to PropertiesProperties
Configure the following properties on the choice list component.
- Anchor to disableddisableddisabledbooleanbooleanDefault: falseDefault: falserequiredrequired
Whether the field is disabled, preventing any user interaction. When
true, thedisabledproperty on any child choices is ignored.- Anchor to namenamenamestringstringrequiredrequired
The name attribute for the field, used to identify the field's value when the form is submitted. Must be unique within the nearest containing form.
- Anchor to errorerrorerrorstringstringrequiredrequired
An error message displayed below the checkbox to indicate validation problems. When set, the checkbox is styled with error indicators and the message is announced to screen readers.
- Anchor to detailsdetailsdetailsstringstringrequiredrequired
Supplementary text displayed below the checkbox to provide additional context, instructions, or help. Use this to explain what checking the box means or provide guidance to users. This text is announced to screen readers.
- Anchor to multiplemultiplemultiplebooleanbooleanDefault: falseDefault: falserequiredrequired
Whether multiple choices can be selected.
- Anchor to labellabellabelstringstringrequiredrequired
The text displayed as the field label, which identifies the purpose of the field to users. This label is associated with the field for accessibility and helps users understand what information to provide.
- Anchor to labelAccessibilityVisibilitylabelAccessibilityVisibilitylabelAccessibilityVisibility"visible" | "exclusive""visible" | "exclusive"Default: 'visible'Default: 'visible'requiredrequired
Controls whether the label is visible to all users or only to screen readers.
visible: The label is shown to everyone (default).exclusive: The label is visually hidden but still announced by screen readers.
Use
exclusivewhen the surrounding context makes the label redundant visually, but screen reader users still need it for clarity.- Anchor to valuesvaluesvaluesstring[]string[]requiredrequired
An array of
valueattributes for the currently selected options. When provided, this property automatically sets theselectedstate on child option components that have matchingvalueattributes. Options with values included in this array will be marked as selected, while others will be unselected.
Anchor to EventsEvents
The choice list component provides event callbacks for handling user interactions. Learn more about handling events.
- Anchor to changechangechangeCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback fired when the choice list selection changes.
Learn more about the change event.
- Anchor to inputinputinputCallbackEventListener<typeof tagName> | nullCallbackEventListener<typeof tagName> | nullrequiredrequired
A callback fired when the user inputs data into the choice list.
Learn more about the input event.
CallbackEventListener
A function that handles events from UI components. This type represents an event listener callback that receives a `CallbackEvent` with a strongly-typed `currentTarget`. Use this for component event handlers like `click`, `focus`, `blur`, and other DOM events.
(EventListener & {
(event: CallbackEvent<T>): void;
}) | nullCallbackEvent
An event object with a strongly-typed `currentTarget` property that references the specific HTML element that triggered the event. This type extends the standard DOM `Event` interface and ensures type safety when accessing the element that fired the event.
Event & {
currentTarget: HTMLElementTagNameMap[T];
}Anchor to ChoiceChoice
The choice component creates individual selectable options within a choice list. Use choice to define each option that merchants can select, supporting both single selection (radio buttons) and multiple selection (checkboxes) modes.
Choice components support labels, help text, and custom content through slots, providing flexible option presentation within choice lists.
- Anchor to disableddisableddisabledbooleanbooleanDefault: falseDefault: falserequiredrequired
Whether the checkbox is disabled, preventing user interaction. Disabled checkboxes appear dimmed and their values aren't submitted with forms.
- Anchor to selectedselectedselectedbooleanbooleanDefault: falseDefault: falserequiredrequired
Whether the option is currently selected. Use this for controlled components where you manage the selection state.
- Anchor to valuevaluevaluestringstringrequiredrequired
The value submitted with the form when this checkbox is checked. If not specified, the default value is "on".
- Anchor to accessibilityLabelaccessibilityLabelaccessibilityLabelstringstringrequiredrequired
A label that describes the purpose or content of the component for assistive technologies like screen readers. Use this to provide additional context when the visible content alone doesn't clearly convey the component's purpose.
- Anchor to defaultSelecteddefaultSelecteddefaultSelectedbooleanbooleanDefault: falseDefault: falserequiredrequired
The initial selected state for uncontrolled components. Use this when you want the option to start selected but don't need to control its state afterward.
Anchor to SlotsSlots
The choice list component supports slots for additional content placement within each choice. Learn more about using slots.
- Anchor to childrenchildrenchildrenHTMLElementHTMLElement
The label text or elements that identify this selectable choice to users.
The label is produced by extracting and concatenating the text nodes from the provided content; any markup or element structure is ignored.
- Anchor to detailsdetailsdetailsHTMLElementHTMLElement
Additional text to provide context or guidance for the input.
This text is displayed along with the input and its label to offer more information or instructions to the user.
Anchor to ExamplesExamples
Anchor to Add a single-select choice listAdd a single-select choice list
Present a group of options for merchants to choose from using radio buttons. This example shows a single-select choice list component with a label, help text, and an onChange handler.
Preview
html
Anchor to Pre-select a default optionPre-select a default option
Set a default selection so merchants see a pre-selected option when the form loads. This example shows a single-select choice list with one option already selected.
Preview
html
Anchor to Enable multiple selections with detailsEnable multiple selections with details
Allow merchants to select more than one option using checkboxes instead of radio buttons. This example shows a multi-select choice list with descriptive details on each option.
Preview
html
Anchor to Show a validation errorShow a validation error
Display an error message when a selection is invalid or a required choice has not been made. This example shows a choice list with a static error message.
Preview
html
Anchor to Disable a choice listDisable a choice list
Disable a choice list to prevent interaction while keeping the current selection visible. This example shows a disabled choice list with a pre-selected option.
Preview
html
Anchor to Best practicesBest practices
- Choose appropriate selection modes: Use single selection for mutually exclusive options like payment methods or shipping speeds. Enable
multiplewhen merchants can select more than one. - Write clear, specific labels: Use choice labels that describe the outcome, like Email notifications for new orders rather than just Email. Keep labels concise but descriptive enough that merchants understand each option without additional explanation.
- Write clear titles: Use titles that pose a clear question or statement, like Which shipping method? or Select notification preferences. Avoid vague titles like Options or Settings.
- Add context to complex choices: Use the
detailsslot on individual choices (for example,<s-text slot="details">) to explain implications when needed. - Provide actionable validation: Show specific error messages like Please select at least one notification preference rather than generic Required field.
Anchor to LimitationsLimitations
- The component doesn't include search, filtering, or lazy loading. For large option sets (20+ choices), consider using a select dropdown instead.
- Rendering 50+ checkboxes or radio buttons can cause noticeable performance issues, especially on mobile devices. Consider pagination, virtualization, or alternative UI patterns for large lists.
- The component is either single-selection (radio buttons) or multiple-selection (checkboxes) for all choices. You can't mix both types in the same list.
- Component types other than choice can't be used as options within the choice list.