Skip to content

Code Block

A code sample with syntax colors from the tokens, a copy button that's always visible, line numbers and diff lines. For a key, use Kbd; for a word of code in a sentence, use <code>.

Sourcecomponents/code-block.tsx

Usage

When to use

Use when

A code sample, a command, or a diff, with useHighlightedCode for syntax colors, a copy button, lineNumbers and line variants. Requires shiki

Don’t use when

A key or shortcut (use Kbd); a word of code inside a sentence (use <code>); an editable code field (use Textarea)