Code Block
A beautiful code snippet component with syntax highlighting and copy functionality.
Preview
example.ts
1
2
3
function helloWorld() {
console.log("Hello, World!");
}Installation
Use the CLI to add this component to your project.
Usage
tsx
15 linesCopy
Examples
Standard Layout
example.ts
1
2
3
function helloWorld() {
console.log("Hello, World!");
}Browser Window Layout
app.tsx
1
2
3
function helloWorld() {
console.log("Hello, World!");
}Props
| Prop | Type | Description |
|---|---|---|
code* | string | The source code to display. |
language | string | Programming language for syntax highlighting (e.g., 'typescript', 'javascript', 'css') (default: 'typescript'). |
filename | string | Optional filename or title to display in the header. |
showLineNumbers | boolean | Whether to show line numbers (default: true). |
browserLayout | boolean | If true, renders a browser-like window header (traffic lights) (default: false). |
className | string | Additional CSS classes. |