
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
react-mui-richtext
Advanced tools
Rich text editor component for React with Material-UI, based on React Quill
A flexible and extensible rich text editor component for React with Material-UI, based on React Quill.
npm install react-mui-richtext
# or
yarn add react-mui-richtext
npm install react react-dom @mui/material @mui/icons-material
Note: The following dependencies are automatically installed with this package:
react-quillreact-easy-cropquill-emojiYou need to import the required CSS files in your application:
import 'react-quill/dist/quill.snow.css';
import 'quill-emoji/dist/quill-emoji.css';
Add these imports in your main entry file (e.g., main.tsx, index.tsx, or App.tsx).
import React, { useState } from 'react';
import { RichTextEditor } from 'react-mui-richtext';
// Don't forget to import CSS files
import 'react-quill/dist/quill.snow.css';
import 'quill-emoji/dist/quill-emoji.css';
function App() {
const [content, setContent] = useState('');
return (
<RichTextEditor
name="editor"
value={content}
onChange={setContent}
placeholder="Start typing..."
/>
);
}
| Prop | Type | Default | Description |
|---|---|---|---|
name | string | required | Field name for the editor |
value | string | required | HTML content value |
onChange | (value: string) => void | required | Callback when content changes |
onBlur | () => void | - | Callback when editor loses focus |
disabled | boolean | false | Disable the editor |
placeholder | string | '' | Placeholder text |
rows | number | 10 | Number of rows (affects height) |
height | string | number | - | Custom height (overrides rows) |
error | boolean | false | Show error state |
| Prop | Type | Default | Description |
|---|---|---|---|
allowImageUpload | boolean | true | Enable image upload button |
maxImageSize | number | 2097152 (2MB) | Maximum image size in bytes |
maxImageCount | number | 5 | Maximum number of images |
enableImageCompress | boolean | true | Enable automatic image compression |
maxImageWidth | number | 1920 | Maximum image width in pixels |
maxImageHeight | number | 1080 | Maximum image height in pixels |
imageQuality | number | 0.8 | Image quality (0-1) |
enableImageCrop | boolean | true | Enable image cropping before upload |
cropAspectRatio | number | - | Fixed aspect ratio for cropping (e.g., 210/297 for A4) |
allowOriginalImageUpload | boolean | false | Enable original size image upload button |
| Prop | Type | Default | Description |
|---|---|---|---|
allowEmoji | boolean | true | Enable emoji picker |
| Prop | Type | Default | Description |
|---|---|---|---|
config | RichTextEditorConfig | {} | Configuration object (see below) |
renderToolbar | (defaultToolbar: ReactNode) => ReactNode | - | Custom toolbar renderer |
renderCropDialog | (props: CropDialogProps) => ReactNode | - | Custom crop dialog renderer |
The config prop allows you to customize various aspects of the editor:
interface RichTextEditorConfig {
// Alert function for notifications
handleAlert?: (message: string, type?: 'success' | 'error' | 'warning' | 'info') => void;
// Custom LoadingButton component
LoadingButton?: React.ComponentType<LoadingButtonProps>;
// Custom toolbar items
customToolbarItems?: ToolbarItem[];
// Custom formats
customFormats?: string[];
// Custom modules
customModules?: Record<string, any>;
// Custom styles
customStyles?: RichTextEditorStyles;
}
import { RichTextEditor, RichTextEditorConfig } from 'react-mui-richtext';
import { useSnackbar } from 'notistack';
import { LoadingButton } from '@mui/lab';
function MyEditor() {
const { enqueueSnackbar } = useSnackbar();
const config: RichTextEditorConfig = {
handleAlert: (message, type = 'info') => {
enqueueSnackbar(message, { variant: type });
},
LoadingButton: LoadingButton,
customStyles: {
container: {
'& .ql-toolbar': {
backgroundColor: '#f5f5f5',
},
},
},
};
return (
<RichTextEditor
name="editor"
value={content}
onChange={setContent}
config={config}
/>
);
}
<RichTextEditor
name="editor"
value={content}
onChange={setContent}
renderToolbar={(defaultToolbar) => (
<Box>
{defaultToolbar}
<Button onClick={handleCustomAction}>Custom Action</Button>
</Box>
)}
/>
<RichTextEditor
name="editor"
value={content}
onChange={setContent}
renderCropDialog={(props) => (
<CustomCropDialog {...props} />
)}
/>
<RichTextEditor
name="editor"
value={content}
onChange={setContent}
enableImageCrop={true}
cropAspectRatio={210 / 297} // A4 size
/>
<RichTextEditor
name="editor"
value={content}
onChange={setContent}
allowImageUpload={false}
/>
The component uses Material-UI's sx prop for styling. You can customize styles through the config.customStyles prop:
const config = {
customStyles: {
container: {
'& .ql-toolbar': {
backgroundColor: '#fafafa',
border: '1px solid #e0e0e0',
},
'& .ql-editor': {
minHeight: '300px',
},
},
},
};
The editor automatically compresses images that exceed the size limit or are larger than 500KB. Compression maintains aspect ratio and reduces quality until the image fits within the size limit.
When enableImageCrop is enabled, users can:
cropAspectRatio is provided)Full TypeScript support is included. Import types as needed:
import type {
RichTextEditorProps,
RichTextEditorConfig,
CropDialogProps,
LoadingButtonProps,
} from 'react-mui-richtext';
MIT
FAQs
Rich text editor component for React with Material-UI, based on React Quill
We found that react-mui-richtext demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.