Skip to main content
  1. Docs
  2. Components
  3. Data display

Code block

Code to read and copy: a command, a snippet, a JSON event or XML metadata, coloured, with one Copy button.

Import
@qeetrix/react/experimental
Status
ExperimentalSince 0.0.6
Renders
<pre>Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

Keyboard

KeysWhat happens
TabTabTo Copy, then to the code region when its lines scroll.
←→Scroll the region sideways, while it has focus.

02

Behaviour

Region
A <section> named by the title, or "Code"; it takes focus, unless wrap.
Copy
Named "Copy code"; it says "Copied" as it copies.
Line numbers
Drawn by CSS: never read, never copied.

03

Tested

On every change, before it ships.

  • axe, WCAG 2.2 A and AA, in Chromium on every pull request
  • Firefox and WebKit every night
  • Numbers and dates in English and Hindi, grouped for India
  • Forced colours and right to left
Next — Code blockChangelog