CodeEditor
The CodeEditor component wraps Monaco Editor with Payload's styling and automatic height behavior.
Import
CodeEditor loads Monaco eagerly. Use CodeEditorLazy to defer loading the editor until it renders, which keeps Monaco out of the initial bundle of a Client Component.
Read-only usage
Set defaultLanguage to enable the appropriate syntax highlighting. Use readOnly when displaying code that should not be edited.
Common props
These are the props most commonly used with this component. See its exported types in @payloadcms/ui for the complete list.
Prop | Type | Default | Description |
|---|---|---|---|
| | — | Code displayed by the editor. |
| | — | Sets the Monaco language used for highlighting. |
| | — | Runs when editable content changes. |
| | | Prevents editing. |
| | | Sets the minimum editor height in pixels. |
| | — | Caps the automatically calculated height. |
| | — | Overrides supported Monaco Editor options. |
| | — | Triggers height recalculation when increased. |
Was this page helpful?