Data display
Code block
Code to read or copy, with a caption and a Copy button; it can draw a highlighter's tokens.
pnpm add @elsikora/keystone-ui-kitInstallation
pnpm add @elsikora/keystone-ui-kitUsage
import { CodeBlock } from "@elsikora/keystone-ui-kit";import { CodeBlock } from "@elsikora/keystone-ui-kit";
export default function CodeBlockDefaultExample() { return <CodeBlock label="shell" code="pnpm add @elsikora/keystone-ui-kit" />;}Examples
Default
pnpm add @elsikora/keystone-ui-kitHighlighted
Tones are drawn by the kit's theme; no colour crosses the API.
// settle the roundconst win = stake * 2;Without Copy
KEYSTONE_PORT=8080API reference
CodeBlock
| Prop | Type | Default | Description |
|---|---|---|---|
code | string | - | The text: what is copied, and what is drawn without tokens. |
label | string | - | A caption: a file name, a shell. |
copy | boolean | true | A Copy button in the caption row. |
copyLabels | { copy: string; copied: string; failed: string } | { copy: "Copy", copied: "Copied", failed: "Copy failed" } | The button's words, and what is said when the copy is done or refused. |
tokens | ReadonlyArray<ReadonlyArray<{ content: string; tone?: TCodeTone }>> | - | Lines of tokens drawn in place of code. |
Notes
- The code scrolls sideways and takes the keyboard's focus; Copy says "Copied" to a screen reader.