# Code Block

Themed editor card with syntax colors, line numbers and a file tab that can type code out, focus lines and mark a diff.

```bash
npx shadcn add https://www.reelcn.dev/r/code-block.json
```

Usage:

```tsx
<Center>
  <CodeBlock
    title="render.ts"
    language="ts"
    code={'const video = await render({\n  fps: 30,\n  codec: "h264",\n});'}
    typing={45}
    highlightLines={[3]}
  />
</Center>
```

Use for:

- Showing an API, config file or snippet in a launch, docs or tutorial video
- Typing code on screen, then focusing the lines that matter

Avoid:

- Shell sessions with commands and output. Use `terminal`


## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| delay? | `number` | — | Frames to wait before entering. |
| duration? | `number` | — | Enter duration in frames. Defaults to 0.6s. Some items reuse `duration` for an unrelated local timing. See that item's own prop docs. |
| exit? | `number \| boolean` | — | Exit at the end of the parent `<Sequence>`. `false` keeps it on screen, a number sets the exit length in frames. |
| motion? | `MotionPersonality` | — | Override the theme's motion personality. |
| poster? | `boolean` | — | Renders fully entered, with no exit: for a still frame or thumbnail. Defaults to `false`. |
| holdFrames? | `number` | — | Delays the start of the exit window by this many frames, for a minimum on-screen hold. Defaults to `0`. |
| code | `string` | — |  |
| language? | `CodeLanguage` | `"ts"` |  |
| title? | `string` | — | File name shown in the tab. |
| typing? | `number` | — | Types the code out at this many characters per second. Omit to show it all at once. |
| highlightLines? | `number[]` | `[]` | 1-based lines to focus: the rest dim and the focused lines get an accent band. |
| highlightAt? | `number` | — | Frame the focus and diff bands sweep in. Defaults to just after the code is fully shown. |
| diff? | `{ add?: number[]; remove?: number[]; }` | — | 1-based lines marked as added or removed. |
| lineNumbers? | `boolean` | `true` |  |
| fontSize? | `number` | `30` | Largest font size in design units. It shrinks so the longest line and every row fit. |
| width? | `number` | — | Largest card width as a fraction of the safe area (0–1). Defaults to 0.72 in landscape, 1 otherwise. |
| colors? | `Partial<Record<TokenKind, string>>` | — | Per-token colors. Defaults derive from the theme (see `tokenColors`). |
| background? | `string` | — | Editor background. Defaults to the theme surface. |
| borderColor? | `string` | — |  |
| addColor? | `string` | — | Added-line color. Defaults to green, because the theme has no status colors. |
| removeColor? | `string` | — | Removed-line color. Defaults to red. |
| radius? | `number` | — | Corner radius in design units. Defaults to 70% of the theme radius. |
| follow? | `CaretFollow` | — | Zooms the camera to trail the caret as it types. Omitted (default): today's behavior, unchanged. |
| style? | `CSSProperties` | — |  |
| className? | `string` | — |  |