Code Block

A code block with syntax highlighting.

Usage

Examples

With a title

useHistory()

Collapsable

Size

sm
md
lg

Props

PropTypeDefaultDescription
code*string-The code string to display.
languageLanguage'text'Programming language for syntax highlighting.
titlestring-Title to display above the code block.
filestring-File name to display above the code block.
size'sm' | 'md' | 'lg''md'Size of the code block.
showLineNumbersbooleantrueWhether to show line numbers.
copyToClipboardbooleantrueWhether to show the copy button.
highlightstring-Line numbers to highlight (e.g., '1,3-5').
maxHeightstring-Maximum height of the code block.
isCollapsablebooleanfalseWhether the code block can be collapsed.
isCollapsedbooleanfalseWhether the code block starts collapsed.
explainWithAibooleantrueWhether to show the AI explain button.