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
labelstringAccessible label for the code block
classNamestringAdditional CSS class names merged onto the root element.

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