Content

Code

Inline code and keys, and a block with a filename header and a copy action.

Examples

Inline

Press ⌘ K to search, set --ae-hue, or highlight anything.

Block

tokens/scale.css
--ae-phi: 1.618034;
--ae-space-5: round(calc(var(--ae-unit) * var(--ae-phi)), 1px);

Anatomy

codeInline code on a small tinted fill.
kbdOne key or one shortcut per element; a bottom hairline makes it read as a keycap.
markHighlighted text on a warning tint.
figure.codeBlock with a header. A bare <pre> works too, without the header.
> figcaptionFilename, monospace and muted, with an optional copy button at the end.
> pre > codeThe code. Scrolls sideways when lines are long.

API

AttributeValuesDescription
data-copy<selector>On a button: aequitas.js copies the text of the element the selector names. Bare, it copies the <pre> of the closest .code.

Behaviour

Clicking a [data-copy] button writes the text to the clipboard and shows "Copied" on the button for a moment. Without aequitas.js the button renders but does nothing.

From aequitas.js. It initialises itself and enhances markup added later on its own, so it works the same in an SPA.

Accessibility

  • The "Copied" label swap is not reliably announced. Pair it with a toast when the confirmation matters.
  • A <pre> that scrolls sideways needs tabindex="0" in browsers that don't make scroll containers focusable, so keyboard users can reach the overflow.
  • Symbols such as ⌘ are read inconsistently. Name the key in the surrounding text when it matters.
  • <mark> is not announced by most screen readers. Say why the text is highlighted when that is the point.
Jump to
ProportionFoundations
MaterialFoundations
PresetsFoundations
ShellLayouts · Application
Container and stacksLayouts · Pages
SplitLayouts · Pages
Grid, bento, masonryLayouts · Pages
Switcher and rowLayouts · Pages
↑↓Move↵OpenescClose