---
title: "Using the Vue 3 Editor Component"
description: "Bind the Vue 3 Editor with v-model in script setup, drive init from ref or computed, toggle disabled or readonly, and call methods via a template ref."
head:
- - meta
- name: robots
content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1'
- - meta
- name: googlebot
content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1'
- - meta
- name: bingbot
content: 'index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1'
---
Are you an LLM? You can read better optimized documentation at https://raw.githubusercontent.com/eramitgupta/erag/main/text-editor-vue/docs/usage.md
# Using the Editor Component in Vue 3
In a Vue 3 single-file component, `` from `@erag/text-editor-vue` binds its HTML with `v-model`. Inside `
```
You can also explicitly pass `:model-value` and listener `@update:model-value`:
```vue
```
---
## Toolbar Presets
### Minimal Toolbar
For comment sections, chat boxes, or simple input forms, you can configure a minimal toolbar and hide the menubar and statusbar:
```vue
```
### Full Custom Toolbar
You can separate groups using `|` or pass specific control names. Each keyword is described in [text formatting](./text-formatting.html) and [lists and indentation](./lists-and-indentation.html):
```ts
const fullConfig: EditorInit = {
height: 450,
minHeight: 250,
maxHeight: 800,
placeholder: 'Type your story here...',
menubar: true,
toolbar:
'undo redo | blocks fontfamily fontsize lineheight | bold italic underline strikethrough superscript subscript casechange | ' +
'forecolor backcolor | alignment | ' +
'bullist numlist checklist outdent indent | link image media table | hr removeformat | ' +
'code preview fullscreen',
statusbar: true,
resize: true,
};
```
---
## Menubar Configuration
Customized menubar entries can be array-defined or hidden entirely. The full list of menu names is in [menubar customization](./menubar-customization.html):
```vue
```
---
## Disabled and Readonly Modes
`@erag/text-editor-vue` supports both `disabled` and `readonly` modes:
- **`disabled`**: Disables all interactions, toolbar buttons, and user editing canvas.
- **`readonly`**: Allows viewing, text selection, source code inspection, and preview while preventing content mutation.
```vue
```
---
## Reactive Configuration
Since Vue 3 reactivity is fully supported, you can drive the editor's `:init` settings dynamically with `ref` or `computed`:
```vue
```
---
## Programmatic Control (`EditorInstance`)
Access the editor instance methods via Vue's template ref:
```vue
```
### Available Instance Methods
| Method | Parameters | Description |
| :------------------------- | :--------- | :------------------------------------------------------- |
| `focus()` | none | Focuses the editable canvas. |
| `blur()` | none | Blurs focus from the editor. |
| `getHtml()` | none | Returns sanitized HTML string. |
| `setHtml(html: string)` | `html` | Sets editor HTML content. |
| `getText()` | none | Returns plain text content without HTML tags. |
| `clear()` | none | Replaces the content with an empty string. |
| `insertHtml(html: string)` | `html` | Inserts HTML fragment at current selection cursor. |
| `insertText(text: string)` | `text` | Inserts raw text fragment. |
| `selectAll()` | none | Selects all text inside editor. |
| `undo()` | none | Triggers programmatic undo step. |
| `redo()` | none | Triggers programmatic redo step. |
| `openSourceCode()` | none | Opens the HTML source code modal dialog. |
| `openPreview()` | none | Opens the sanitized preview modal dialog. |
| `getRootElement()` | none | Returns the editable content root inside `.erag-editor`. |