Code block

A readable, selectable source surface with optional file identity, semantic syntax color, line reference, and Copy. Inline Code still names one identifier; Code block presents a complete expression or file excerpt.

Source file

The header is compositional: add filename, language, and Copy only when they help. Line numbers stay hidden for short examples and appear when surrounding content refers to lines.

Code block · TypeScript
app/page.tsxTypeScript
Copy code
import { Button } from "@/components/ui";export default function Page() {  return <Button intent="primary">Deploy</Button>;}

Copy changes to a check on success and announces the result. Line numbers are shown here for source reference; the highlighted fourth line is attention, not a diff.

Line meaning

Highlight, addition, and removal are separate meanings. Diff lines pair semantic color with a start rule and generated mark, so color never carries the change alone.

Code block · Diff
theme.tsTypeScript
Copy code
const radius = 8;const radius = 12;// Highlight is neutral attention.

Axes

AxisDefaultAlternativeBoundary
FrameFramed--plainPlain only when a parent already owns the surface and inset
Line numbersHidden--line-numbersShow when prose, review, or errors refer to lines
Inline scrollSelf--host-scrollHost is for a parent region that owns both scroll axes

Usage notes

VerdictRule
DoPre-render escaped highlighting into the semantic token classes while preserving exact text and reading order.
DoUse optional filename, language, and Copy for a source artifact; omit the header for a small contextual example.
DoKeep generated numbers and diff marks out of selection and copied source.
Don’tWrap long lines or add a component max-height; the host owns vertical measure.
Don’tBuild language switching, line linking, collapse, or Open in v0 into the base component; those are product compositions.