Skip to main content

Code Block

Show code with a file name or tabs, a copy button & marked lines.

View as Markdown

Installation

Component API

PropTypeDefaultDescription
codestring-The text to show, and what Copy puts on the clipboard.
The text to show, and what Copy puts on the clipboard.
linesReactNode[]-
titlestring-A file name in the header, beside a file icon.
A file name in the header, beside a file icon.
iconReactNode-A glyph before title, in place of the file icon.
A glyph before title, in place of the file icon.
tabsCodeBlockTab[]-Versions of the same snippet, one per tab, such as package managers.
Versions of the same snippet, one per tab, such as package managers.
highlightLinesnumber[]-Lines to mark, counting from 1.
Lines to mark, counting from 1.
lineNumbersbooleantrueNumbers down the left.
Numbers down the left.
maxLinesnumber20
fillbooleanfalseTakes its container's height and scrolls inside it, in place of maxLines.
Takes its container's height and scrolls inside it, in place of maxLines.
copyLabelstringCopyWhat the copy button says.
What the copy button says.
copiedLabelstringCopiedWhat the copy button says for a moment once it has copied.
What the copy button says for a moment once it has copied.
shapenone | rounded | pillrounded
animatedbooleantrue
classNamestring-
focusboolean | stringtrue