froala/react-froala-wysiwyg
On GitHub, froala/react-froala-wysiwyg has picked up 2 stars, JavaScript. React component for Froala WYSIWYG HTML Rich Text Editor.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Snapshot
Top contributors
Show top contributors
React JS Froala WYSIWYG Editor
react-froala-wysiwyg provides React bindings to the Froala WYSIWYG editor.
It supports React 0.14 through 19. The function component examples below use hooks, which need React 16.8 or later.
Table of contents
- Installation
- Update editor version
- Usage
- Config
- Events and Methods
- Model
- Special tags
- Manual Instantiation
- Displaying HTML
- Custom Buttons
- Usage with Server-Side Rendering
- TypeScript
- React StrictMode
- License
- Development environment setup
Installation
Install the wrapper and froala-editor together, with froala-editor at the exact version the wrapper depends on:
npm install --save-exact react-froala-wysiwyg froala-editor@$(npm view react-froala-wysiwyg dependencies.froala-editor)
This works in bash, zsh and PowerShell. In Windows cmd, run npm view react-froala-wysiwyg dependencies.froala-editor first, then npm install --save-exact react-froala-wysiwyg froala-editor@ followed by the version it printed. --save-exact keeps froala-editor at that version in package.json, so a later install can't pull in a newer patch next to the wrapper's copy.
The samples below import froala-editor directly (its CSS, plugins and the FroalaEditor class), so it has to be a direct dependency. npm happens to hoist the wrapper's copy, but pnpm and Yarn PnP don't, and the build fails to resolve froala-editor/css/....
Don't install a different froala-editor version. With two copies, plugins and custom buttons register on your copy while the wrapper creates the editor from its own, so they silently don't show up.
Update editor version
react-froala-wysiwyg pins the exact froala-editor version it was built and tested against, so update the wrapper to get a newer editor, and move froala-editor to the version the new wrapper depends on:
npm install --save-exact react-froala-wysiwyg@latest froala-editor@$(npm view react-froala-wysiwyg@latest dependencies.froala-editor)
In Windows cmd, run the npm view part on its own and paste the version, as above.
Usage
1. Import and use the Froala Editor component inside your application.
import React from 'react';
import ReactDOM from 'react-dom/client';
// Require Editor CSS files.
import 'froala-editor/css/froala_style.min.css';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import FroalaEditorComponent from 'react-froala-wysiwyg';
// Import all Froala Editor plugins;
// import 'froala-editor/js/plugins.pkgd.min.js';
// Import a single Froala Editor plugin.
// import 'froala-editor/js/plugins/align.min.js';
// Import a language file.
// import 'froala-editor/js/languages/de.js';
// Import a third-party plugin.
// import 'froala-editor/js/third_party/image_tui.min.js';
// import 'froala-editor/js/third_party/embedly.min.js';
// import 'froala-editor/js/third_party/spell_checker.min.js';
// Include font-awesome css if required.
// install using "npm install font-awesome"
// import 'font-awesome/css/font-awesome.css';
// import 'froala-editor/js/third_party/font_awesome.min.js';
// Include special components if required.
// import FroalaEditorView from 'react-froala-wysiwyg/FroalaEditorView';
// import FroalaEditorA from 'react-froala-wysiwyg/FroalaEditorA';
// import FroalaEditorButton from 'react-froala-wysiwyg/FroalaEditorButton';
// import FroalaEditorImg from 'react-froala-wysiwyg/FroalaEditorImg';
// import FroalaEditorInput from 'react-froala-wysiwyg/FroalaEditorInput';
// Render Froala Editor component.
const root = ReactDOM.createRoot(document.getElementById('editor'));
root.render(<FroalaEditorComponent tag='textarea'/>);
react-dom/client and createRoot need React 18 or later. On React 17 and earlier, use import ReactDOM from 'react-dom' and ReactDOM.render(<FroalaEditorComponent tag='textarea'/>, document.getElementById('editor')) instead.
2. Add an element with that id to your HTML.
<div id="editor"></div>
In an app created with a tool like Vite, render <FroalaEditorComponent/> inside one of your components instead. The examples below assume FroalaEditorComponent and the special components are imported as shown above.
Component props
<FroalaEditorComponent
tag='textarea'
config={config}
model={model}
onModelChange={handleModelChange}
/>
- tag: the element the editor is initialized on (default:
div). - config: editor options.
- model: the editor content. See Model.
- onModelChange: called with the new content when it changes. See Model for when it fires.
- onManualControllerReady: see Manual Instantiation.
- skipReset: when
true, setting a newmodelfrom outside the editor keeps the editor's undo history instead of resetting it. See Undo history andskipReset.
There are special tags: a, button, img, input. Do not use them in FroalaEditorComponent. To initialize the editor on a special tag, use FroalaEditorA, FroalaEditorButton, FroalaEditorImg and FroalaEditorInput components.
Config
You can pass editor options as component attribute (optional).
config={config}
You can pass any existing Froala option. Consult the Froala documentation to view the list of all the available options:
config={{
placeholderText: 'Edit Your Content Here!',
charCounterCount: false
}}
Additional option is used:
- immediateReactModelUpdate: (default: false) This option updates the React model as soon as a key is released in the editor. Note that it may affect performance.
Changing config after mount
config is read once, when the editor is created. If you change it later (a new placeholderText, a different language, a toolbar that depends on state), the editor that's already running won't pick it up. To apply new options, re-mount the component by giving it a key that changes along with them:
// Import the language file for each locale you switch to.
<FroalaEditorComponent
key={locale}
tag='textarea'
config={{ language: locale }}
model={model}
onModelChange={setModel}
/>
When key changes, React destroys the old editor and creates a new one with the current config. The content comes back from model, so keep it in state as above. Undo history starts fresh with the new editor.
Events and Methods
Events can be passed in with the options, with a key events and object where the key is the event name and the value is the callback function. Inside the callback, this is the editor instance, so use a regular function rather than an arrow function:
config={{
placeholderText: 'Edit Me',
events : {
'focus' : function() {
console.log(this.selection.get());
}
}
}}
Using the editor instance you can call editor methods as described in the method docs.
Froala events are described in the events docs.
Model
The WYSIWYG HTML editor content model.
model={model}
Two way binding:
import React, { useState } from 'react';
import FroalaEditorComponent from 'react-froala-wysiwyg';
import FroalaEditorView from 'react-froala-wysiwyg/FroalaEditorView';
const App = () => {
const [model, setModel] = useState('Example Set');
return (
<div className="App">
<FroalaEditorComponent
tag='textarea'
model={model}
onModelChange={setModel}
/>
<FroalaEditorView
model={model}
/>
</div>
);
}
The same with a class component:
import React from 'react';
import FroalaEditorComponent from 'react-froala-wysiwyg';
class EditorComponent extends React.Component {
constructor () {
super();
this.handleModelChange = this.handleModelChange.bind(this);
this.state = {
model: 'Example text'
};
}
handleModelChange (model) {
this.setState({
model: model
});
}
render () {
return <FroalaEditorComponent
model={this.state.model}
onModelChange={this.handleModelChange}
/>
}
}
onModelChange is called on the editor's contentChanged event, and on every keyup too when immediateReactModelUpdate is set. For the editor's HTML, it's only called when the content differs from the last value the component passed in or out, so loading model on mount doesn't call it when it's already the editor's HTML.
To achieve one way binding and pass only the initial editor content, simply do not pass onModelChange attribute.
Use the content in other places:
<input value={model} readOnly/>
Undo history and skipReset
When the parent passes in a model the editor didn't produce itself (loading a different document, say), the component sets it in the editor and clears the undo history, so Undo can't step back into the previous content. Passing the editor's own value back in from onModelChange, as two-way binding does, isn't affected: the component recognises the value it just emitted and leaves the editor and its history alone.
To keep the history across external changes, pass skipReset:
<FroalaEditorComponent
tag='textarea'
model={model}
onModelChange={setModel}
skipReset={true}
/>
With skipReset, the external change becomes one more undo step, so Undo takes the editor back to what it held before.
Special tags
You can also use the editor on img, button, input and a tags.
These need the editor's plugins: image for FroalaEditorImg and link for FroalaEditorA. Without them the element renders, but clicking it does nothing. Import the plugins, as in the commented-out line in Usage:
import 'froala-editor/js/plugins.pkgd.min.js';
<FroalaEditorImg
model={imgModel}
onModelChange={setImgModel}
/>
<FroalaEditorButton
model={buttonModel}
onModelChange={setButtonModel}
/>
<FroalaEditorInput
model={inputModel}
onModelChange={setInputModel}
/>
<FroalaEditorA
model={linkModel}
onModelChange={setLinkModel}
/>
The model must be an object containing the attributes for your special tags. Example:
const [imgModel, setImgModel] = useState({
src: 'path/to/image.jpg',
width: '300px',
alt: 'Old Clock'
});
- The model can contain a special attribute named innerHTML which inserts innerHTML in the element: If you are using 'button' tag, you can specify the button text like this:
const [buttonModel, setButtonModel] = useState({innerHTML: 'Click Me'});
As the button text is modified by the editor, the innerHTML attribute of the button's model will be modified too.
Specific option for special tags
- reactIgnoreAttrs: (default: null) This option is an array of attributes that you want to ignore when the editor updates the model:
config={{
reactIgnoreAttrs: ['class', 'id']
}}
Manual Instantiation
Gets the functionality to operate on the editor: create, destroy and get editor instance. Use it if you want to manually initialize the editor.
When onManualControllerReady is set, the editor doesn't start on mount. It starts when you call initialize():
import { useState } from 'react';
import FroalaEditorComponent from 'react-froala-wysiwyg';
function ManualEditor() {
const [initControls, setInitControls] = useState(null);
const handleManualController = (controls) => {
setInitControls(controls);
};
const initializeEditor = () => {
initControls.initialize();
};
const deleteAll = () => {
const editor = initControls && initControls.getEditor();
if (editor && editor.html) {
editor.html.set('');
}
};
return (
<>
<button onClick={initializeEditor} disabled={!initControls}>Initialize</button>
<button onClick={deleteAll}>Delete All</button>
<FroalaEditorComponent onManualControllerReady={handleManualController} />
</>
);
}
getEditor() returns null until initialize() has run, and the editor isn't ready the moment initialize() returns either, so don't call its methods on the next line. Guard them as deleteAll does, or use them from the initialized event.
The object received by the function will contain the following methods:
- initialize: Call this method to initialize the Froala Editor
- destroy: Call this method to destroy the Froala Editor
- getEditor: Call this method to retrieve the editor that was created. This method will return null if the editor was not yet created
Using a ref
The same three methods are on the component itself, so a ref reaches the editor too. With a ref the editor still starts on mount, unless onManualControllerReady is also set:
import { useRef } from 'react';
import FroalaEditorComponent from 'react-froala-wysiwyg';
function EditorWithRef() {
const editorRef = useRef(null);
const deleteAll = () => {
const editor = editorRef.current && editorRef.current.getEditor();
if (editor && editor.html) {
editor.html.set('');
}
};
return (
<>
<button onClick={deleteAll}>Delete All</button>
<FroalaEditorComponent ref={editorRef} />
</>
);
}
In TypeScript, type it as useRef<FroalaEditorComponent>(null).
Displaying HTML
To display content created with the froala editor use the FroalaEditorView component.
<FroalaEditorComponent
model={content}
onModelChange={setContent}
/>
<FroalaEditorView
model={content}
/>
FroalaEditorView renders model as raw HTML and does not sanitize it. Only pass content you trust, and sanitize HTML loaded from storage or from other users first (on the server, or with a library such as DOMPurify).
Custom Buttons
You can pass the custom buttons to the editor by following way:
import FroalaEditor from 'froala-editor';
FroalaEditor.DefineIcon('alert', {NAME: 'info', SVG_KEY: 'help'});
FroalaEditor.RegisterCommand('alert', {
title: 'Hello',
focus: false,
undo: false,
refreshAfterCallback: false,
callback: function () {
alert('Hello!');
}
});
FroalaEditor.DefineIcon('clear', {NAME: 'remove', SVG_KEY: 'remove'});
FroalaEditor.RegisterCommand('clear', {
title: 'Clear HTML',
focus: false,
undo: true,
refreshAfterCallback: true,
callback: function () {
this.html.set('');
this.events.focus();
}
});
FroalaEditor.DefineIcon('insert', {NAME: 'plus', SVG_KEY: 'add'});
FroalaEditor.RegisterCommand('insert', {
title: 'Insert HTML',
focus: true,
undo: true,
refreshAfterCallback: true,
callback: function () {
this.html.insert('My New HTML');
}
});
Now you can use these buttons in options:
<FroalaEditorComponent
config={{
toolbarButtons: [['undo', 'redo', 'bold'], ['alert', 'clear', 'insert']]
}}
/>
Usage with Server-Side Rendering
The editor needs a browser, so on the server render nothing and load the editor in the browser. Importing react-froala-wysiwyg during server rendering fails, even from a 'use client' file.
Next.js
Put the editor in its own client component:
// app/editor/FroalaClient.jsx
'use client';
import 'froala-editor/css/froala_style.min.css';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/js/plugins.pkgd.min.js';
import FroalaEditorComponent from 'react-froala-wysiwyg';
import { useState } from 'react';
export default function FroalaClient() {
const [model, setModel] = useState('<p>Hello</p>');
return (
<FroalaEditorComponent
tag='textarea'
model={model}
onModelChange={setModel}
config={{ placeholderText: 'Start writing…' }}
/>
);
}
Then load it with next/dynamic and ssr: false, from another client component:
// app/editor/Editor.jsx
'use client';
import dynamic from 'next/dynamic';
const FroalaClient = dynamic(() => import('./FroalaClient'), {
ssr: false,
loading: () => <p>Loading editor…</p>,
});
export default function Editor() {
return <FroalaClient />;
}
And render Editor from the page:
// app/editor/page.jsx
import Editor from './Editor';
export default function Page() {
return <Editor />;
}
Pages and other server components should import Editor, never FroalaClient. Importing FroalaClient directly brings back the server-rendering failure.
Register custom buttons, icons and languages inside FroalaClient.jsx too, so they only run in the browser.
Other SSR frameworks
Use React lazy loading. It also lets plugins and translations load before the editor is created, so the editor picks them up. If your framework uses React Server Components, start the file with 'use client'.
Functional component
import React, { Suspense, useEffect, useState } from 'react';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/css/froala_style.min.css';
const FroalaEditor = React.lazy(() => import('react-froala-wysiwyg'));
export default function MyComponent() {
const [isInitialized, setIsInitialized] = useState(false);
const [content, setContent] = useState('Hello, Froala!');
useEffect(() => {
async function initPlugins() {
// Import all Froala Editor plugins;
await import('froala-editor/js/plugins.pkgd.min.js');
setIsInitialized(true);
}
initPlugins();
}, []);
return <>
{isInitialized && (
<Suspense fallback={<p>Loading...</p>}>
<FroalaEditor
model={content}
onModelChange={setContent}
/>
</Suspense>
)}
</>;
}
Class component
import React, { Suspense } from 'react';
import 'froala-editor/css/froala_editor.pkgd.min.css';
import 'froala-editor/css/froala_style.min.css';
const FroalaEditor = React.lazy(() => import('react-froala-wysiwyg'));
export default class MyComponent extends React.Component {
constructor () {
super();
this.state = {
isInitialized: false,
content: 'Hello, Froala!'
};
}
componentDidMount() {
// Import all Froala Editor plugins;
import('froala-editor/js/plugins.pkgd.min.js').then(() => this.setState({isInitialized: true}));
}
render() {
return <>
{this.state.isInitialized && (
<Suspense fallback={<p>Loading...</p>}>
<FroalaEditor
model={this.state.content}
onModelChange={(content) => this.setState({content})}
/>
</Suspense>
)}
</>;
}
}
TypeScript
The package ships its own type definitions (lib/index.d.ts) for react-froala-wysiwyg and each react-froala-wysiwyg/FroalaEditor* component, so in most projects TypeScript picks them up without any extra setup.
The react-froala-wysiwyg/FroalaEditor* types are declared in that same file, so they only load once something imports react-froala-wysiwyg itself. If your project imports only a subpath, such as a read-only page that uses just FroalaEditorView, add this line to a .d.ts file in your project (for example src/froala.d.ts):
/// <reference types="react-froala-wysiwyg" />
The props are typed: config takes the editor's options plus the wrapper's own (immediateReactModelUpdate, reactIgnoreAttrs), onModelChange receives a string (an attribute map for the special tags), and getEditor() returns the editor instance, or null before it's created. The package also exports the types it uses, such as FroalaEditorConfig, FroalaEditorProps and ManualController:
import type { FroalaEditorConfig } from 'react-froala-wysiwyg';
const config: FroalaEditorConfig = { placeholderText: 'Edit Me', immediateReactModelUpdate: true };
froala-editor has types for the options and the editor instance. In strict mode, type this in event callbacks:
import FroalaEditor from 'froala-editor';
import type { FroalaOptions } from 'froala-editor';
const config: Partial<FroalaOptions> = {
placeholderText: 'Edit Me',
events: {
focus: function (this: FroalaEditor) {
console.log(this.selection.get());
}
}
};
React StrictMode
In development, StrictMode mounts every component twice, so the editor is created, destroyed and created again. Handlers such as initialized run once for each editor that's created, so twice in development. Production builds mount once.
License
The react-froala-wysiwyg project is under MIT license. However, in order to use Froala WYSIWYG HTML Editor plugin you should purchase a license for it.
Froala Editor has 3 different licenses for commercial use. For details please see License Agreement.
Development environment setup
If you want to contribute to react-froala-wysiwyg, you will first need to install the required tools to get the project going.
Prerequisites
- Node Package Manager (NPM)
- Git
Install dependencies
$ npm install
Build
$ npm run build
Run Demo
$ npm run demo
The demo is served at http://localhost:4000. It uses the built files, so run npm run build first.
Related repositories
Master programming by recreating your favorite technologies from scratch.
A curated meta-list of curated lists organized by technology domain. The repository acts as a directory pointing to hundreds of specialized awesome lists covering programming languages, platforms, frameworks, and tooling. All content is community-contributed under the CC0 public domain dedication.
Public APIs is a community-curated GitHub repository listing free, publicly accessible APIs across a wide range of categories, with auth type, HTTPS, and CORS noted for each entry. It's a browsable reference, not a library to install.
REA is an MCP server and CLI that gives AI coding agents the ability to reverse engineer binaries, JavaScript apps, .NET assemblies, and websites. It hooks into Hopper, Ghidra, or IDA Pro for native binary work, or runs static JavaScript analysis with just Node.js. Every investigation returns an Evidence bundle that includes what was found, what was not, and the reasoning path. Setup registers REA with supported agents and walks you through connecting an analysis engine. The CLI also works standalone for terminal-first workflows.
Quick answers
Does froala/react-froala-wysiwyg have any tags?
TopGit's last sync did not record any GitHub topics for froala/react-froala-wysiwyg. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on froala/react-froala-wysiwyg?
The most recent commit recorded on froala/react-froala-wysiwyg was 6 days ago, based on the GitHub push timestamp. The repository has 1 forks — one of the better signals of community interest.
Is froala/react-froala-wysiwyg open source?
TopGit's metadata for froala/react-froala-wysiwyg does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
Where can I see froala/react-froala-wysiwyg in action?
The project maintains a homepage at https://froala.com/wysiwyg-editor. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about froala/react-froala-wysiwyg?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/froala/react-froala-wysiwyg is the definitive source.
Read full README in the tab above.
Still deciding about react-froala-wysiwyg?
One click hands the question to an AI along with this page — see what it says about react-froala-wysiwyg.