Code Editor
Editable code component with real-time syntax highlighting using the CSS Custom Highlight API. Supports line numbers, read-only state, placeholder text, and custom tokenizers.
@astryxdesign/lab
Usage
Editable code component with real-time syntax highlighting using the CSS Custom Highlight API. Supports line numbers, read-only state, placeholder text, and custom tokenizers.
Typed props
| Prop | Type and behavior |
|---|---|
value | string · requiredControlled string value for the editor. |
onChange | (value: string) => void · requiredCallback fired when the code content changes. |
label | string · requiredAccessible label for the editable region (aria-label). |
language | string · default 'plaintext'Programming language for syntax highlighting. |
hasLineNumbers | boolean · default falseDisplay line number gutter on the left. |
isReadOnly | boolean · default falseRenders the editor in a read-only state. |
placeholder | stringPlaceholder text displayed when value is empty. |
maxHeight | number | stringMaximum container height before internal scrolling. |
size | 'sm' | 'md' · default 'md'Font size variant for the code text. |
tokenizer | (code: string, language: string) => TokenLine[]Custom tokenizer function override for language parsing. |
xstyle | StyleXStylesStyleX styles for layout customization. |