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.
: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).
| Prop | Type | Default | Description |
|---|---|---|---|
coderequired | string | - | The code. |
className | string | - | Extra class names for the root element. |
copy | boolean | true | Copy button. Default true. |
lineNumbers | boolean | - | Shows line numbers. |
title | ReactNode | - | Shown above the code, e.g. a file name or "bash". |
CopyButton props
Copies a value and confirms it, announced to screen readers.
| Prop | Type | Default | Description |
|---|---|---|---|
valuerequired | string | - | The text to copy. |
appearance | "button" | "icon" | 'icon' | icon (default) or a button with the label. |
label | string | '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).
| Prop | Type | Default | Description |
|---|---|---|---|
childrenrequired | string | - | The text to animate, word by word. |
stagger | number | 60 | Delay 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.