CodeBlock
Syntax-highlighted code display with optional line numbers, highlighting, and copy.
Props
CodeLanguage is a string union: "ts" | "js" | "tsx" | "jsx" | "json" | "bash" | "sql" | "css" | "yaml" | "text".
| Prop | Type | Default | Description |
|---|---|---|---|
code | string | — | The source code string to display. |
language | CodeLanguage | "text" | Language for syntax highlighting. |
title | ReactNode | — | File name or label in the header bar. |
showLineNumbers | boolean | — | Shows line numbers in the gutter. |
copyable | boolean | true | Shows a copy button. |
highlightLines | number[] | — | 1-based line numbers to tint. |
maxLines | number | — | Collapses to this many lines with a toggle. |
wrap | boolean | — | Soft-wrap instead of scrolling horizontally. |
startLine | number | 1 | Starting line number for excerpts. |
Examples
import { CodeBlock } from "@solarius/onset";
import type { CodeLanguage } from "@solarius/onset";