Code Block
Displays code, terminal output and diffs with an optional header, line numbers and a copy button. Pass language for Shiki Dark+ highlighting. Content stays dir="ltr".
Syntax Highlighting
Set language on CodeBlockContent (e.g. language="tsx") for Dark+ colors.
Installation
CLI
Also needs
npx @sonojs/ui@latest add button use-highlighted-code && npm i lucide-react shikiUsage
code-block.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" · "destructive" | "default" | Tone of the block surface. |
| size | "default" · "sm" | "default" | Density. Small suits tool / trace output. |
| language | string | — | On CodeBlockContent — Shiki id (`tsx`, `json`, `bash`, …). |
| wrap | boolean | false | On CodeBlockContent — wrap long lines. |
| lineNumbers | boolean | false | On CodeBlockContent — show a line number gutter. |
| startLine | number | 1 | On CodeBlockContent — first line number in the gutter. |