Components › Display
Code block
A block of code with a file name, line numbers, marked lines and a copy button.
Installation
npx plankui@latest add code-blockUsage
import { CodeBlock } from "@/components/ui/code-block";
<CodeBlock code={source} filename="app.tsx" lineNumbers highlightLines={[3]} />API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| code | string | required | The code. JavaScript, TypeScript and JSX are coloured. |
| filename | string | "Code" | Shown in the header. |
| lineNumbers | boolean | false | Number each line. |
| highlightLines | number[] | [] | 1-based lines to mark. |
| syntax | boolean | true | Turn off for shell output or plain text. |