Codeblock
Syntax highlighted code blocks with language icons
The CodeBlock component renders code with syntax highlighting, language icons, and a copy button.
Usage
With title
Add a title to display in the header:
Language icons
CodeBlock displays icons for supported languages:
- typescript, javascript
- python, rust, go
- bash, shell
- json, yaml
- html, css
- jsx, tsx
- markdown
Aliases are supported: ts maps to typescript, js to javascript, sh to bash, yml to yaml.
Copy button
The copy button appears in the header when a title or language is set. Without a label, it floats in the top-right corner. Clicking copies the code content to clipboard.
Props
| prop | type | default | description |
|---|---|---|---|
| children | ReactNode | required | Code content to display |
| lang | string | - | Language for icon and label |
| title | string | - | Title shown in header |
| lines | boolean | false | Show line numbers |
Twoslash integration
Twoslash metadata is rendered as notes below the code block when annotations are present: