UI Library

CodeEditor

Prop Type Default Value Notes
autoFocusbooleanfalse
Focuses the editor once it mounts.
containerClassstring?'h-full overflow-hidden rounded-[var(--editor-frame-radius,0.5rem)] border border-slate-700 bg-slate-950'
Classes for the outer wrapper; the default renders the framed editor box (override for a light theme).
contentstring—
Bindable editor document. The eye resets to the default content.
docTypestring?'text'
Language pack key: json, javascript, html, markdown, yaml, or xml (loaded on demand). 'text' loads none.
editablebooleantrue
Enables typing; false renders read-only.
editorAriaLabelstring?'Content'
Accessible name for the editor textbox.
editorClassstring?'h-full'
Classes for the CodeMirror host; it fills the wrapper by default.
maxContentLengthnumber?0
Caps the document length; 0 disables the cap.
recreateKeystring?''
Changing it destroys and rebuilds the editor.
selectionEnabledbooleantrue
Allows text selection and copy.
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | number'md'
Editor text scale; numbers are icon-scale pixels. The font, content padding, and mark radius follow it.
themestring?'dark'
'dark' uses githubDark, any other value githubLight.
onAutoFocused() => void——Called after an autofocus.
onContentChange(content: string) => void——Called with the document after every edit.
onReady() => void——Called once the EditorView exists.
onSelectionChange(range: { from; to } | null) => void——Called with the selection range, or null when collapsed.