Code block
On this page
Keyboard interactions
Users should have the ability to move focus to each button using a keyboard.
| Key | Result |
|---|---|
| Tab | Moves focus to code numbers and text (if numbers are visible) |
| Tab | Moves focus to the copy to clipboard button and displays a tooltip |
| Enter | Copies code text to clipboard (when copy to clipboard button has focus) |
| Tab | Moves focus to the toggle overflow button or toggle word wrapping button and displays a tooltip |
| Enter | Toggles overflow or word wrapping (when either button has focus) |
| Tab | Moves focus to the Show more button |
| Enter | Expands or collapses code text (when focus is on expand/collapse button) |
Focus order
A logical focus order helps keyboard users operate our websites. Elements need to receive focus in an order that preserves meaning, therefore the focus order should make sense and not jump around randomly.
Touch targets
All buttons exceed the WCAG Level AA success criteria for target size, which calls for touch targets to be at least 24px by 24px.
ARIA Authoring Practices Guide (APG)
Learn to use the accessibility semantics defined by the Accessible Rich Internet Application (ARIA) specification to create accessible web experiences.
Web Content Accessibility Guidelines
Automated testing
Some of our elements may receive errors or warnings that are false positives from automated testing tools. If you are experiencing some of these issues, please read our update on false positives in automated tools.
Understanding documents provide detailed explanations for Web Content Accessibility Guidelines (WCAG) guidelines and success criteria.
-
SC 2.1.1 Keyboard (Level A)
-
SC 2.1.3 Keyboard (no exception) (Level AAA)
-
SC 2.4.3 Focus order (Level A)
-
SC 2.5.8 Target size (Minimum) (Level AA)
Other libraries
To learn more about our other libraries, visit this page.
Feedback
To give feedback about anything on this page, contact us.