lara-light-indigo

Editor

Editor is rich text editor component based on Quill.

Default
Customized
Import via Module

import { Editor } from 'primereact/editor';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/editor/editor.min.js"></script>
 
Getting Started

Editor is used as a controlled component with value and onTextChange properties.


<Editor style={{height:'320px'}} value={text} onTextChange={(e) => setText(e.htmlValue)} />
 
Toolbar

Editor provides a default toolbar with common options, to customize it define your elements with the headerTemplate. Refer to Quill documentation for available controls.


const header = (
    <span className="ql-formats">
        <button className="ql-bold" aria-label="Bold"></button>
        <button className="ql-italic" aria-label="Italic"></button>
        <button className="ql-underline" aria-label="Underline"></button>
    </span>
);

<Editor style={{height:'320px'}} value={text} onTextChange={(e) => setText(e.htmlValue)} headerTemplate={header}/>
 
Properties
NameTypeDefaultDescription
idstringnullUnique identifier of the element.
valuestringnullValue of the content.
styleobjectnullInline style of the container.
classNamestringnullStyle class of the container.
placeholderstringnullPlaceholder text to show when editor is empty.
readOnlybooleanfalseWhether to instantiate the editor to read-only mode.
modulesobjectnullModules configuration, see here for available options.
formatsstring[]nullWhitelist of formats to display, see here for available options.
headerTemplateanynullStyle and modules of the toolbar.
Events
NameParametersDescription
onTextChangeevent.delta: Representation of the change.
event.source: Source of change. Will be either "user" or "api".
event.htmlValue: Current value as html.
event.textValue: Current value as text.
Callback to invoke when text of editor changes.
onSelectionChangeevent.range: Object with index and length keys indicating where the selection exists.
event.oldRange: Object with index and length keys indicating where the previous selection was.
event.source: Source of change. Will be either "user" or "api".
Callback to invoke when selected text of editor changes.
onLoadquill: Quill instanceCallback to invoke when the quill modules are loaded.

Refer to Quill documentation for more information.

Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-editor-containerContainer element
p-editor-toolbarToolbar of the editor
p-editor-contentEditable area
Dependencies

Quill Editor 1.3+.

Resources of quill needs to be added to your application.


npm install quill
 

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma