npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-mui-richtext

v1.0.2

Published

Rich text editor component for React with Material-UI, based on React Quill

Readme

React MUI RichText Editor

A flexible and extensible rich text editor component for React with Material-UI, based on React Quill.

Features

  • 📝 Full-featured WYSIWYG Editor - Based on React Quill with comprehensive formatting options
  • 🖼️ Image Upload & Management - Upload, compress, crop, and manage images
  • 🎨 Material-UI Integration - Seamless integration with Material-UI components
  • ⚙️ Highly Configurable - Extensive configuration options for customization
  • 🔌 Extensible - Support for custom toolbar items, formats, modules, and render functions
  • 📱 Responsive - Works well on desktop and mobile devices
  • 🎯 TypeScript Support - Full TypeScript definitions included

Installation

npm install react-mui-richtext
# or
yarn add react-mui-richtext

Peer Dependencies

npm install react react-dom @mui/material @mui/icons-material

Note: The following dependencies are automatically installed with this package:

  • react-quill
  • react-easy-crop
  • quill-emoji

CSS Import

You 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).

Basic Usage

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..."
    />
  );
}

Props

Basic Props

| 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 |

Image Upload Props

| 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 |

Feature Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | allowEmoji | boolean | true | Enable emoji picker |

Extension Props

| 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 |

Configuration Object

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;
}

Example with Configuration

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}
    />
  );
}

Advanced Usage

Custom Toolbar

<RichTextEditor
  name="editor"
  value={content}
  onChange={setContent}
  renderToolbar={(defaultToolbar) => (
    <Box>
      {defaultToolbar}
      <Button onClick={handleCustomAction}>Custom Action</Button>
    </Box>
  )}
/>

Custom Crop Dialog

<RichTextEditor
  name="editor"
  value={content}
  onChange={setContent}
  renderCropDialog={(props) => (
    <CustomCropDialog {...props} />
  )}
/>

A4 Aspect Ratio Cropping

<RichTextEditor
  name="editor"
  value={content}
  onChange={setContent}
  enableImageCrop={true}
  cropAspectRatio={210 / 297} // A4 size
/>

Disable Image Upload

<RichTextEditor
  name="editor"
  value={content}
  onChange={setContent}
  allowImageUpload={false}
/>

Styling

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',
      },
    },
  },
};

Image Compression

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.

Image Cropping

When enableImageCrop is enabled, users can:

  • Drag to move the crop box
  • Resize the crop box by dragging corners/edges
  • Adjust zoom level
  • Rotate the image
  • Set fixed aspect ratio (if cropAspectRatio is provided)

TypeScript

Full TypeScript support is included. Import types as needed:

import type {
  RichTextEditorProps,
  RichTextEditorConfig,
  CropDialogProps,
  LoadingButtonProps,
} from 'react-mui-richtext';

License

MIT