Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-quill

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-quill

The Quill rich-text editor as a React component.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is react-quill?

react-quill is a React component for Quill, a powerful rich text editor. It provides a customizable and extensible interface for creating and editing content with a variety of formatting options.

What are react-quill's main functionalities?

Basic Usage

This code demonstrates the basic usage of react-quill. It imports the necessary modules, sets up a state to hold the editor's content, and renders the ReactQuill component.

import React, { useState } from 'react';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';

function MyEditor() {
  const [value, setValue] = useState('');
  return (
    <ReactQuill value={value} onChange={setValue} />
  );
}

export default MyEditor;

Custom Toolbar

This code demonstrates how to create a custom toolbar for the react-quill editor. It defines a CustomToolbar component and uses it in the MyEditor component, specifying the custom toolbar in the modules prop.

import React, { useState } from 'react';
import ReactQuill, { Quill } from 'react-quill';
import 'react-quill/dist/quill.snow.css';

const CustomToolbar = () => (
  <div id="toolbar">
    <button className="ql-bold">Bold</button>
    <button className="ql-italic">Italic</button>
    <select className="ql-color">
      <option value="red"></option>
      <option value="green"></option>
      <option value="blue"></option>
    </select>
  </div>
);

function MyEditor() {
  const [value, setValue] = useState('');
  return (
    <div>
      <CustomToolbar />
      <ReactQuill value={value} onChange={setValue} modules={{ toolbar: '#toolbar' }} />
    </div>
  );
}

export default MyEditor;

Formats and Modules

This code demonstrates how to specify custom formats and modules for the react-quill editor. It defines the formats and modules arrays and passes them as props to the ReactQuill component.

import React, { useState } from 'react';
import ReactQuill from 'react-quill';
import 'react-quill/dist/quill.snow.css';

const formats = [
  'header', 'bold', 'italic', 'underline', 'strike', 'blockquote',
  'list', 'bullet', 'indent',
  'link', 'image'
];

const modules = {
  toolbar: [
    [{ 'header': '1' }, { 'header': '2' }, { 'font': [] }],
    [{ 'list': 'ordered'}, { 'list': 'bullet' }],
    ['bold', 'italic', 'underline', 'strike', 'blockquote'],
    ['link', 'image'],
    [{ 'align': [] }]
  ]
};

function MyEditor() {
  const [value, setValue] = useState('');
  return (
    <ReactQuill value={value} onChange={setValue} modules={modules} formats={formats} />
  );
}

export default MyEditor;

Other packages similar to react-quill

Keywords

FAQs

Package last updated on 03 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc