Code Block
Server ComponentSource snippet with header, line numbers and copy.
Import
tsx
import { CodeBlock } from "@cronus-ui/ui";
bash
npx cronus-ui add code-block
Examples
.cronus
The same component declared in Cronus. Emitted at build time from the audit fixtures — the kernel renders it as HTML with no React.
default.cronus
app "audit-fixtures" {
port 5176
}
style {
preset aurora
theme dark
}
component CodeBlockDefault layout:inline style:code-block {
filename:"index.ts"
language:"ts"
label "const n = 1;"
text "const n = 1;"
}
page "/audit/code-block/default" type:custom {
use CodeBlockDefault
}
API Reference
Generated from the component's exported types.
CodeBlockProps
Extends Omit<HTMLAttributes<HTMLDivElement>, "children">
| Prop | Type | Default | Description |
|---|---|---|---|
code* | string | — | Raw source to render and copy. |
language | string | — | Language label rendered as a Badge in the header. |
filename | string | — | File name rendered in the header. |
showLineNumbers | boolean | false | Render a gutter with 1-based line numbers. Defaults to false. |
className | string | — | Additional class names merged onto the root. |
id | string | — | DOM id of the root element. |