Skip to main content

ChoiceList

Present multiple options to users, allowing either single selections with radio buttons or multiple selections with checkboxes.

boolean
Default: false

Disables the field, disallowing any interaction.

disabled on any child choices is ignored when this is true.

string

Indicate an error to the user. The field will be given a specific stylistic treatment to communicate problems that have to be resolved immediately.

string

A unique identifier for the element.

string

Content to use as the field label.

Anchor to labelAccessibilityVisibility
labelAccessibilityVisibility
'visible' | 'exclusive'
Default: 'visible'

Changes the visibility of the component's label.

  • visible: the label is visible to all users.
  • exclusive: the label is visually hidden but remains in the accessibility tree.
boolean
Default: false

Whether multiple choices can be selected.

string

An identifier for the field that is unique within the nearest containing form.

string[]

An array of the values of the selected options.

This is a convenience prop for setting the selected prop on child options.

'auto' | 'list' | 'inline' | 'block' | 'grid'
Default: 'auto'

The variant of the choice grid.

  • auto: The variant is determined by the context.
  • list: The choices are displayed in a list.
  • inline: The choices are displayed on the inline axis.
  • block: The choices are displayed on the block axis.
  • grid: The choices are displayed in a grid.
Was this section helpful?

Learn more about registering events.

<typeof tagName>

A callback that is run whenever the control is changed.

Was this section helpful?

Create options that let users select one or multiple items from a list of choices.

string

A label used for users using assistive technologies like screen readers. When set, any children or label supplied will not be announced. This can also be used to display a control without a visual label, while still providing context to users using screen readers.

boolean
Default: false

Whether the control is active by default.

boolean
Default: false

Disables the control, disallowing any interaction.

boolean
Default: false

Set to true to associate a choice with the error passed to ChoiceList

string

A unique identifier for the element.

boolean
Default: false

Whether the control is active.

string

The value used in form data when the control is checked.

Was this section helpful?

Learn more about component slots.

HTMLElement

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.

HTMLElement

Secondary content for a choice.

HTMLElement

Content to display when the option is selected.

This can be used to provide additional information or options related to the choice.

Was this section helpful?

Code

<s-choice-list>
<s-choice defaultSelected value="location-1"
>Yonge-Dundas Square locations</s-choice
>
<s-choice value="location-2">Distillery District location</s-choice>
<s-choice value="location-3">Yorkville location</s-choice>
</s-choice-list>

Preview

The ChoiceList component offers different variants to suit various use cases. Choose the right variant based on the number of choices, the complexity of the content, and the available screen space. Below are some best practices for each variant.

This classic and flexible variant is ideal for up to 10 choices. It’s the most common and recognizable format for making a selection from a vertical list.

Best Practices

  • Keep it simple: Keep the initial content for each item as concise as possible so users can quickly scan and compare their choices.
  • Add extra content strategically: Only use the "selected content" slot if the information is essential and directly tied to the selected item. For example, a map that shows the location of a chosen address is an effective use case. If the content doesn’t need to be in close proximity to the selected item, place it elsewhere on the page to reduce visual clutter.

This variant is designed for options that require both secondary content and a clear visual separation. It’s well-suited for up to 5 choices where each item is complex and needs its own defined space. Due to its "chunky" footprint, using more than 5 can take up too much vertical space.

Best Practices

  • Focus on clarity: Use this variant to help users compare options with more complexity than a simple list, such as an item with a title, a description, and a price.
  • Be intentional with extra content: Just like the List variant, only include extra content when it’s crucial for the user to make a final decision and when its close proximity to the selected block is a benefit.

This compact variant is ideal when screen real estate is limited. It works best for up to 3 to 5 choices depending on the typical length of the content.

Best Practices

  • Keep content short and simple: Due to its horizontal layout, content for each item must be succinct, simple, and short, especially on mobile.
  • Avoid extra content: This variant does not support extra content upon selection, so it’s best for a scenario where the user's decision doesn’t require additional information.

This variant is best for up to 6 choices, arranged in a grid-like layout. It’s great for scenarios where choices have significant visual differences and need to be arranged for easy comparison.

Best Practices

  • Keep content short and simple: The content in each item needs to be succinct and simple because the horizontal and vertical constraints of the grid can limit the available space.
  • Avoid extra content: This variant does not support extra content upon selection, so it’s best for a scenario where the user's decision doesn’t require additional information.
Was this section helpful?

List Variant

<s-choice-list>
<s-choice defaultSelected value="location-1">Yonge-Dundas Square</s-choice>
<s-choice value="location-2">Distillery District</s-choice>
<s-choice value="location-3">Yorkville</s-choice>
</s-choice-list>

Preview