Skip to content
Design System
GitHub

Code block

v0.19.0Beta

Code or a command with a copy button: wraps a command between words, scrolls source sideways, hides a one-time secret until shown. Takes a highlighter's output as children.

Roles

What a screen reader is told each part is, measured in the examples on the Overview tab.

  • button
  • group
  • Follows the WAI-ARIA pattern Button.
  • Announces changes through a live region, so a screen reader reads an update without focus moving to it.

Keyboard

KeysAction
TabMove to Show (a secret), Copy, then the code when it scrolls
←→Scroll the focused code sideways
EnterSpaceOn Show, show or hide the secret; on Copy, copy the code

Colour contrast

Computed from the shipped theme for the colours this component uses, on page and card backgrounds; the lower of the two is shown. WCAG 2.2 AA.