Code Block
Syntax-highlighted source the reader will scan or paste. Pair with Snippet for a one-line command.
Default
Pass filename and language so the header and highlighter have something to work with.
No filename
Omit the header when the snippet is ephemeral. Copy sits on the block instead.
Highlighted lines
Mark only the lines under discussion. Highlighting every line is the same as highlighting none.
Added and removed
Use addedLinesNumbers and removedLinesNumbers. Do not fake a diff with comments — those copy with the snippet.
Referenced lines
Click a line number to pin that row and write #L{n} into the URL.
Language switcher
switcher renders a dropdown in the header. Keep options in sync with the slot text.
Tabs
tabs replaces the dropdown with a segmented control. Do not pass both unless you want tabs to win.
Hidden line numbers
export function formatBytes(bytes: number) {
if (bytes === 0) return '0 B'
const units = ['B', 'KB', 'MB', 'GB']
let value = bytes
let index = 0
while (value >= 1024 && index < units.length - 1) {
value /= 1024
index += 1
}
return value.toFixed(1) + ' ' + units[index]
}
Open in v0
v0 adds a toolbar action. ask opens the snippet as a question. build prefixes the prompt with Build this.
Best practices
- Use
Code Blockfor multi-line source. One token (path, flag, env name) stays inline. A copyable shell command isSnippet. - Always set
language(or thesyntaxalias). This highlighter understandsts,js,tsx,next,lua,bash, andjson. - Show
filenamewhen the reader has a paste destination. Drop it for throwaway examples. - Highlight the few lines you are talking about. Added and removed rows belong on the dedicated number props, not in comments.
- Keep snippets runnable. Do not wrap shell in
$— that is Snippet's job. - Put the source in the default slot as text. The block reads slot text for copy and highlighting; do not nest interactive nodes inside it.