Skip to content

Monaco Component

Overview

The <monaco> component provides a powerful code editor based on the Monaco Editor (the same editor that powers VS Code). It supports syntax highlighting, code completion, and other advanced editing features for various programming languages.

Usage

html
<monaco v-model="code" language="javascript"></monaco>

Props

PropTypeDefaultDescription
modelValueString''The code content (use with v-model)
languageString'javascript'Programming language for syntax highlighting
themeString'vs'Editor theme ('vs', 'vs-dark', 'hc-black')
readOnlyBooleanfalseWhether the editor is read-only
minimapBooleantrueWhether to show the minimap
lineNumbersString'on'Line number display ('on', 'off', 'relative')
wordWrapString'off'Word wrapping ('off', 'on', 'wordWrapColumn', 'bounded')
fontSizeNumber14Font size in pixels
tabSizeNumber2Tab size in spaces
heightString'300px'Height of the editor

Events

EventParametersDescription
update:modelValue(value: string)Emitted when the code content changes
editorDidMount(editor: monaco.editor.IStandaloneCodeEditor)Emitted when the editor is mounted
change(value: string)Emitted when the code content changes

Examples

Basic Usage

html
<monaco v-model="javascriptCode" language="javascript"></monaco>

With Different Language

html
<monaco v-model="htmlCode" language="html"></monaco>

With Dark Theme

html
<monaco v-model="code" language="typescript" theme="vs-dark"></monaco>

Read-Only Mode

html
<monaco v-model="readOnlyCode" :read-only="true" language="json"></monaco>

Custom Height and Font Size

html
<monaco 
  v-model="code" 
  language="python" 
  height="500px" 
  :font-size="16"
></monaco>

Without Minimap

html
<monaco v-model="code" :minimap="false"></monaco>

u00a9 Velocitech LTD. All rights reserved.

Released under the Apache License 2.0.