Code or a command with a copy button: wraps a command between words, scrolls source sideways, hides a one-time secret until shown. Takes a highlighter's output as children.
API reference
Generated from the types. Every part also takes className.
CodeBlock
- coderequired
stringThe exact text; it is what Copy copies, also whenchildrenshows it highlighted.- title
stringShown in the header and names the scroll box, e.g. a file name or "Terminal". Never put a secret here.- language
stringShown in the header when there is no title.- wrap
"none" | "words" = "none""words" for shell commands (wrap between words, never inside a name); "none" scrolls sideways.- lineNumbers
boolean = falseNumbers each line in a gutter that stays put while the code scrolls; hidden from screen readers. With wrap="none" only.- secret
boolean = falseHide the value behind dots, with a Show toggle; Copy still copies the real value.- copyLabel
stringThe copy button's name, as is. Without it the name comes fromlabels.copy(title)("Copy <title>", "Copy code").- labels
Partial<CodeBlockLabels>- children
ReactNodeHighlighted code (a<pre>from shiki or similar) shown in place of the plain text.