Content
CodeBlock
Code container with optional window chrome, filename and language labels, and a copy button that says so when the copy fails. Pass raw code in code, or children for highlighted JSX.
Preview
Installation
Resolves dependencies, copies the source, and installs npm packages automatically.
Usage
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| code | string | - | Raw code string copied to the clipboard. Required. |
| filename | string | - | Label shown on the left of the chrome |
| language | string | - | Language tag shown on the right (e.g. bash, tsx, css) |
| meta | string | - | Secondary label between filename and language |
| variant | "default" | "terminal" | "default" | `terminal` adds three macOS-style window dots |
| showCopy | boolean | true | Toggle the copy button |
| copyTimeout | number | 1500 | How long the 'copied' state stays visible (ms) |