Dropdown
CNo accessibility annotations are needed for dropdowns, but keep these considerations in mind if you are modifying Carbon or creating a custom component.
What Carbon provides
Carbon bakes keyboard operation into its components, improving the experience of blind users and others who operate via the keyboard. Carbon incorporates many other accessibility considerations, some of which are described below.
Keyboard interactions
A dropdown component and its variants multiselect and combobox are reached by
Tab
, with navigation of the options by Up
and Down
arrow keys. However,
the keys for opening the component and selecting its options are different for
each variant.
Dropdowns are in the tab order and operable by Up and Down arrow keys, once opened.
The dropdown opens with Enter
, Space
or Down arrow
, with focus moving to
the selected option. Options are selected with Space
or Enter
, which also
closes the dropdown. Pressing Esc
or Tab
closes a dropdown without changing
the selected option.
The multiselect opens with Enter
or Space
, which are also used to toggle the
selection of any option. Once items are selected, a tag appears in the field,
showing a numerical representation of the number of items selected along with an
‘x’. Pressing Esc
closes the multiselect. Pressing Delete
while focus is in
the collapsed field will clear all selected options.
The combobox has significantly different operation, since it is a combination of
a text input and a dropdown. Enter
or Down arrow
will open the list of
options, as will typing any character or string of characters (which will also
filter the list to only show items that match the typed string). Pressing Esc
will clear the input and collapse the list. Pressing Enter
will select a
highlighted option and collapse the combobox. (If nothing is highlighted in the
list, pressing Enter
will just toggle the combobox open and closed.) Space
cannot be used for selecting, as pressing it will submit a space character into
the filter string.
Development considerations
Keep these considerations in mind if you are modifying Carbon or creating a custom component.
- The dropdown and multiselect variant use a
button
witharia-haspopup="listbox"
. - The combobox uses an input with
role="combobox"
,aria-autocomplete="list"
,aria-haspopup="listbox"
andautocomplete="off"
. - The combobox uses
aria-controls
for a div withrole="listbox"
. - All variants use
aria-expanded
to track the state of the listbox. - See the ARIA authoring practices for combobox for more considerations.