Select

A select component allows users to choose from a predefined list of options. You can click or tap on it, and it reveals a list of options and you can select the option that aligns with your preference.

UsageCodeAccessibility

Keyboard interactions

CommandDescription
TabWhen focus is outside the select, moves focus to the input container.
Space/EnterOpens/closes the select panel
Arrow KeysOnce you are in the opened select panel you can navigate to the next option by using the right or down arrow key. You can navigate back to the previous option with left or up. The focus indicator loops, so when you are at the last option and press "down" it will focus on the first option.
HomeWhen focus is inside the select panel, moves to the first available option item in the select panel
EndWhen focus is inside the select panel, moves to the last available option item in the select panel

WAI-ARIA

In the component itself we use multiple aria-attributes to assure the component works well with a range of assistive technologies. For some attributes however it is not possible for the Design System to add a meaningful value, because it relies on the context or way a component is used.

Attributes that we recommend you add in certain scenarios are mentioned below.

Select

AttributeValueDescription
aria-labelstringDefines a string that labels the action that will be performed when the user interacts with the select. Needs to be added when the select is not wrapped with sl-form-field and there is no sl-label.
aria-labelledbystringUsed to connect with single header/element that describes the select, when there is no label connected to.

Option group

AttributeValueDescription
aria-labelstringString that labels the select options group. If heading is set this value will be added as the aria-label. When there is no heading please add your own aria-label string.
aria-labelledbystringCan be used to connect with single header/element that describes the select group, when there is no label/heading connected to.