Highlight

Read-only syntax-highlighted code block — the same owned tokenizer as CodeEditor, without the textarea.

Category: display · WCAG 2.1-AA · editor, code, syntax-highlighting, display, read-only

Props

PropTypeDefaultDescription
valuestringCode to render
languagestringplaintextGrammar name (plaintext/json/javascript/typescript/css/html/markdown/bash)
lineNumbersbooleanfalseShow the line-number gutter
wrapbooleanfalseSoft-wrap long lines
tabSizenumber2Spaces per tab stop
ariaLabelstringAlias of `label` — the same invisible accessible name under the catalog spelling. Neither is deprecated.
labelstringAccessible label for the code block
classNamestringAdditional CSS class names merged onto the root element.
gutterRefRef<HTMLDivElement>Ref to the gutter column (used by `CodeEditor` for scroll-sync).
preRefRef<HTMLPreElement>Ref to the scrollable `<pre>` (used by `CodeEditor` for scroll-sync).

Design tokens

When to use

When not to use

Examples

Read-only snippet

import { Highlight } from '@cascivo/editor'
import '@cascivo/editor/styles.css'

<Highlight language="json" value={'{ "ok": true }'} />

Related components

← Back to docs