# Code block

A block of code with a file name, line numbers, marked lines and a copy button. PlankUI component for React 19 and Tailwind CSS v4. Category: Display.

## Install

```bash
npx plankui@latest add code-block
```

## Usage

```tsx
import { CodeBlock } from "@/components/ui/code-block";

<CodeBlock code={source} filename="app.tsx" lineNumbers highlightLines={[3]} />
```

## Props

| 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. |

Source: https://github.com/VectorLabsHQ/plankui/blob/main/components/ui/code-block.tsx
