Skip to content
Alea0.1

Extras

CodeBlock, CopyButton, SplitText

Code with a copy button, a copy button for any value, and a headline that rises in word by word.

import { CodeBlock, CopyButton, SplitText } from '@alea/ui';

Examples

CodeBlock

Code with a title, line numbers and copy.

tokens.css
:root {
  --alea-accent: #cd57ff;
  --alea-radius-md: 20px;
}

CopyButton

Copy any value; "Copied" is announced.

#CD57FF

SplitText

A headline that rises in word by word.

Design that plays with you

Props

CodeBlock props

Code with a copy button (no highlighter bundled; pass your own highlighted children through code if you need colors).

PropTypeDefaultDescription
coderequiredstring-The code.
classNamestring-Extra class names for the root element.
copybooleantrueCopy button. Default true.
lineNumbersboolean-Shows line numbers.
titleReactNode-Shown above the code, e.g. a file name or "bash".

CopyButton props

Copies a value and confirms it, announced to screen readers.

PropTypeDefaultDescription
valuerequiredstring-The text to copy.
appearance"button" | "icon"'icon'icon (default) or a button with the label.
labelstring'Copy'What is copied, for the label ("Copy hex"). Default "Copy".
onCopy(() => void)-Called after the text is copied.
size"sm" | "md"'sm'sm or md (default).

SplitText props

A headline that rises in word by word (reads as one string to screen readers; still with reduced motion).

PropTypeDefaultDescription
childrenrequiredstring-The text to animate, word by word.
staggernumber60Delay between words in ms. Default 60.

Accessibility

  • CopyButton announces "Copied".
  • SplitText reads as one string; the words are hidden from screen readers.

Do and don't

Do

  • Give code blocks a filename or language label.
  • Keep examples short enough to read without scrolling.

Don't

  • Don't put secrets or real tokens in examples.
  • Don't rely on syntax colors to explain the code.
Tested with axe, keyboard and screen reader roles