Style Appearance Customization in the Vue Rich Text Editor component
16 May 20259 minutes to read
The following content provides the exact CSS structure that can be used to modify the control’s appearance based on the user preference.
Customizing placeholder text
Use the following CSS to customize the default color in the Rich Text Editor’s placeholder.
.e-richtexteditor .e-rte-placeholder {
color: blue;
font-family: monospace;
}
Customizing editor content
Use the following CSS to customize the default Rich Text Editor’s content properties like font-family, font-size and color.
/* To change font family and font size */
.e-richtexteditor .e-rte-content .e-content,
.e-richtexteditor .e-source-content .e-content {
font-size: 20px;
font-family: Segoe ui;
}
/* To change font color and content background */
.e-richtexteditor .e-rte-content,
.e-richtexteditor .e-source-content {
background: seashell;
color: blue;
}
Customizing editor toolbar
Use the following CSS to customize the default color in the Rich Text Editor’s toolbar icon.
/* To change font color for toolbar icon */
.e-richtexteditor .e-rte-toolbar .e-toolbar-item .e-icons,
.e-richtexteditor .e-rte-toolbar .e-toolbar-item .e-icons:active {
color: red;
}
/* To change font color for toolbar button */
.e-toolbar .e-tbar-btn,
.e-toolbar .e-tbar-btn:active,
.e-toolbar .e-tbar-btn:hover {
color: red;
}
/* To change font color for toolbar button in active state*/
.e-richtexteditor .e-rte-toolbar .e-toolbar-item .e-dropdown-btn.e-active .e-icons, .e-richtexteditor .e-rte-toolbar .e-toolbar-item .e-dropdown-btn.e-active .e-rte-dropdown-btn-text {
color: red;
}
/* To change font color for expanded toolbar items */
.e-richtexteditor .e-rte-toolbar .e-toolbar-extended .e-toolbar-item .e-tbar-btn .e-icons,
.e-toolbar.e-extended-toolbar .e-toolbar-extended .e-toolbar-item .e-tbar-btn {
color: red;
}
Customizing character count display
Use the following CSS to customize the default color in the Rich Text Editor’s character count.
/* To change font color, font family, font size and opacity */
.e-richtexteditor .e-rte-character-count {
color: red;
font-family: segoe ui;
font-size: 18px;
opacity: 00.54;
padding-bottom: 2px;
padding-right: 14px;
}
Customizing border color
Use the following CSS to customize the border color in the Rich Text Editor’s container.
.e-richtexteditor .e-rte-container{
border: 2px solid #454bc1;
border-radius: 4px;
}
Highlight the specific lines
Programmatically highlight a portion of the text in the editor by setting the background color. This can be achieved by applying a background style to the selected text using the Rich Text Editor’s executeCommand
method.
<template>
<div>
<button @click="setBackground" class="e-btn" style="margin: 5px">
Apply
</button>
<ejs-richtexteditor
ref="rteObj"
:height="340"
:value="rteValue"
></ejs-richtexteditor>
</div>
</template>
<script setup>
import { provide } from "vue";
import { RichTextEditorComponent as EjsRichtexteditor, Toolbar, Link, Image, HtmlEditor, QuickToolbar } from '@syncfusion/ej2-vue-richtexteditor';
import { NodeSelection } from '@syncfusion/ej2-richtexteditor';
const rteValue = `<p>The Syncfusion Rich Text Editor, a WYSIWYG (what you see is what you get) editor, is a user interface that allows you to create, edit, and format rich text content. You can try out a demo of this editor here.</p><p><b>Key features:</b></p><ul><li><p>Provides <IFRAME> and <DIV> modes.</p></li><li><p>Bulleted and numbered lists.</p></li><li><p>Handles images, hyperlinks, videos, hyperlinks, uploads, etc.</p></li><li><p>Contains undo/redo manager. </p></li></ul><div style='display: inline-block; width: 60%; vertical-align: top; cursor: auto;'><img alt='Sky with sun' src='https://cdn.syncfusion.com/ej2/richtexteditor-resources/RTE-Overview.png' width='309' style='min-width: 10px; min-height: 10px; width: 309px; height: 174px;' class='e-rte-image e-imginline e-rte-drag-image' height='174' /></div>`,
const setBackground(args) = {
const rteInstance = this.$refs.rteObj.ej2Instances;
const rteContent = rteInstance.contentModule.getDocument();
const firstParagraph = rteInstance.contentModule
.getEditPanel()
.querySelector('p');
if (firstParagraph && firstParagraph.firstChild) {
// Select text range using NodeSelection
this.nodeSelection.setSelectionText(
rteContent,
firstParagraph.firstChild,
firstParagraph.firstChild,
4, // Start index
20 // End index
);
// Apply background color
rteInstance.executeCommand('backColor', 'yellow');
}
}
provide('richtexteditor', [Toolbar, Link, Image, HtmlEditor, QuickToolbar]);
</script>
<style>
@import "../../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-vue-richtexteditor/styles/material.css";
</style>
<template>
<div>
<button @click="setBackground" class="e-btn" style="margin: 5px">
Apply
</button>
<ejs-richtexteditor
ref="rteObj"
:height="340"
:value="rteValue"
></ejs-richtexteditor>
</div>
</template>
<script>
import { RichTextEditorComponent, Toolbar, Link, Image, HtmlEditor, QuickToolbar } from '@syncfusion/ej2-vue-richtexteditor';
import { NodeSelection } from '@syncfusion/ej2-richtexteditor';
export default {
name: "App",
components: {
"ejs-richtexteditor": RichTextEditorComponent
},
data() {
return {
rteValue: `<p>The Syncfusion Rich Text Editor, a WYSIWYG (what you see is what you get) editor, is a user interface that allows you to create, edit, and format rich text content. You can try out a demo of this editor here.</p><p><b>Key features:</b></p><ul><li><p>Provides <IFRAME> and <DIV> modes.</p></li><li><p>Bulleted and numbered lists.</p></li><li><p>Handles images, hyperlinks, videos, hyperlinks, uploads, etc.</p></li><li><p>Contains undo/redo manager. </p></li></ul><div style='display: inline-block; width: 60%; vertical-align: top; cursor: auto;'><img alt='Sky with sun' src='https://cdn.syncfusion.com/ej2/richtexteditor-resources/RTE-Overview.png' width='309' style='min-width: 10px; min-height: 10px; width: 309px; height: 174px;' class='e-rte-image e-imginline e-rte-drag-image' height='174' /></div>`,
nodeSelection: new NodeSelection(),
}
},
methods: {
setBackground() {
const rteInstance = this.$refs.rteObj.ej2Instances;
const rteContent = rteInstance.contentModule.getDocument();
const firstParagraph = rteInstance.contentModule
.getEditPanel()
.querySelector('p');
if (firstParagraph && firstParagraph.firstChild) {
// Select text range using NodeSelection
this.nodeSelection.setSelectionText(
rteContent,
firstParagraph.firstChild,
firstParagraph.firstChild,
4, // Start index
20 // End index
);
// Apply background color
rteInstance.executeCommand('backColor', 'yellow');
}
},
},
provide: {
richtexteditor: [Toolbar, Link, Image, HtmlEditor, QuickToolbar]
}
}
</script>
<style>
@import "../../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../../node_modules/@syncfusion/ej2-vue-richtexteditor/styles/material.css";
</style>