Keyboard Navigation
The keyboard navigation of the SegmentedControl is available by default.
The SegmentedControl supports the following keyboard shortcuts:
| Shortcut | Description |
|---|---|
Tab | Moves focus into the SegmentedControl to the selected segment. Pressing Tab again moves focus to the next focusable element on the page. |
Shift + Tab | Moves focus out of the SegmentedControl to the previous focusable element on the page. |
Right Arrow | Moves focus to the next segment. |
Left Arrow | Moves focus to the previous segment. |
Enter & Space | Selects the focused segment. |
The following example demonstrates the keyboard navigation of the SegmentedControl. The control includes a disabled segment and sits between two buttons, so that you can see how Tab and Shift + Tab move focus in and out of the control.
Navigation Behavior
The SegmentedControl uses a roving tab index. Only one item is part of the page tab sequence at a time. The focused item is the tab stop while focus is inside the control, and the selected item is the tab stop when focus is outside.
- Focus does not wrap. Pressing
Right Arrowon the last item orLeft Arrowon the first item keeps focus on the current item. - Moving focus with the arrow keys does not change the selection. To select the focused item, press
EnterorSpace. - In right-to-left mode, the
Left Arrowkey moves focus to the next segment and theRight Arrowkey moves focus to the previous segment.
Disabled Items
Disabled items remain focusable with the arrow keys, so that keyboard users are made aware of their presence and state. Pressing Enter or Space on a disabled item does not select it.