---
title: Quill - Rich Content Editor
product: Form Library
description: Form builder tool with Quill, a rich text editor that enables users to input and format their content with bold, italics, lists, hyperlinks, and more. View a free demo for JavaScript to learn how to integrate Quill into SurveyJS.
framework: React
source: https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/reactjs
index: https://surveyjs.io/form-library/examples/overview.md
---

# Quill - Rich Content Editor (React)

A rich text editor is a tool that allows users to create, edit, and format text using advanced features. For instance, your respondents can apply a bold, italic, or underline font style to text, add bullet points, numbered lists, hyperlinks, adjust text alignment, and more. This demo shows how to integrate the <a href="https://quilljs.com/" target="_blank">Quill</a> text editor into your survey.

For a step-by step Quill integration tutorial, refer to the following documentation articles. Although they describe integration of a color picker, the same instructions apply to any other third-party component, including Quill. 

- [Integrate Third-Party React Components](https://surveyjs.io/form-library/documentation/customize-question-types/third-party-component-integration-react)
- [Integrate Third-Party Angular Components](https://surveyjs.io/form-library/documentation/customize-question-types/third-party-component-integration-angular)
- [Integrate Third-Party Vue 3 Components](/form-library/documentation/customize-question-types/third-party-component-integration-vue)

## Files

### `public/index.html`

```html
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/QuillComponent.jsx`

```js
import React from "react";
import { ElementFactory, Question, Serializer } from "survey-core";
import ReactQuill from "react-quill-new";
import "react-quill-new/dist/quill.snow.css";
import {
    SurveyQuestionElementBase,
    ReactQuestionFactory
} from "survey-react-ui";

// Must use lowercase
const CUSTOM_TYPE = "quill";

// Create a question model
export class QuestionQuillModel extends Question {
    getType() {
        return CUSTOM_TYPE;
    }
    get height() {
        return this.getPropertyValue("height");
    }
    set height(val) {
        this.setPropertyValue("height", val);
    }
}

// Register the model in `ElementFactory`
ElementFactory.Instance.registerElement(CUSTOM_TYPE, (name) => {
    return new QuestionQuillModel(name);
});

// Add question type metadata for further serialization into JSON
Serializer.addClass(
    CUSTOM_TYPE,
    [{ name: "height", default: "200px", category: "layout" }],
    function () {
        return new QuestionQuillModel("");
    },
    "question"
);

// Create a class that renders Quill
export class SurveyQuestionQuill extends SurveyQuestionElementBase {
    constructor(props) {
        super(props);
    }
    get question() {
        return this.questionBase;
    }
    get value() {
        return this.question.value;
    }
    handleValueChange = (val) => {
        this.question.value = val;
    };
    get style() {
        return { height: this.question.height };
    }

    renderQuill() {
        // Support the read-only and design modes
        const isReadOnly = this.question.isReadOnly || this.question.isDesignMode;
        return (
            <ReactQuill
                readOnly={isReadOnly}
                value={this.value}
                onChange={this.handleValueChange}
            />
        );
    }

    renderElement() {
        return <div style={this.style}>{this.renderQuill()}</div>;
    }
}

// Register `SurveyQuestionQuill` as a class that renders `quill` questions
ReactQuestionFactory.Instance.registerQuestion(CUSTOM_TYPE, (props) => {
    return React.createElement(SurveyQuestionQuill, props);
});
```

### `src/SurveyComponent.jsx`

```js
import React from "react";
import { Model } from "survey-core";
import { Survey } from "survey-react-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";
import { SurveyQuestionQuill } from "./QuillComponent";

import { registerFunction } from "survey-core";

function encodeHtml([ input ]) {
    return input
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;');
}
registerFunction({ name: "encodeHtml", func: encodeHtml });

function SurveyComponent() {
    const survey = new Model(json);
    survey.onComplete.add((sender, options) => {
        console.log(JSON.stringify(sender.data, null, 3));
    });
    return (<Survey model={survey} />);
}

export default SurveyComponent;
```

### `src/index.css`

```css
.ql-toolbar.ql-snow {
    white-space: normal;
}
```

### `src/index.js`

```js
import React from "react";
import { createRoot } from "react-dom/client";
import SurveyComponent from "./SurveyComponent";

const root = createRoot(document.getElementById("surveyElement"));
root.render(<SurveyComponent />);
```

### `src/json.js`

```js
export const json = {
  "elements": [
    {
      "type": "quill",
      "name": "rich-text-editor",
      "defaultValue": "Hello world!"
    },
    {
      "type": "html",
      "name": "rich-text-editor-html",
      "html": "{encodedHtml}"
    }
  ],
  "calculatedValues": [{
    "name": "encodedHtml",
    "expression": "encodeHtml({rich-text-editor})"
  }],
  "questionTitleLocation": "hidden",
  "showNavigationButtons": false
}
;
```

### `package.json`

```json
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "react-quill-new": "latest",
    "survey-core": "latest",
    "survey-react-ui": "latest"
  },
  "devDependencies": {
    "react-scripts": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/angular.md)
- [Vue 3](https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/vue3js.md)
- [jQuery](https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/jquery.md)
