Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-markdown-editor

> 前端框架
Open source

A markdown editor with preview, implemented with React.js and TypeScript.

378 stars0 likes1 views
WebsiteGitHub

About

A markdown editor with preview, implemented with React.js and TypeScript.

A markdown editor with preview, implemented with React.js and TypeScript.

Migrate from @uiw/react-markdown-editor 4.x to 5.x.

Install

bash
npm i @uiw/react-markdown-editor

Document

Official document demo preview (中国镜像网站)

Basic Usage

javascript
import React from 'react';
import MarkdownEditor from '@uiw/react-markdown-editor';

const mdStr = `# This is a H1  \n## This is a H2  \n###### This is a H6`;

const Dome = () => {
  return (
     {

      }}
    />
  )
};

export default Dome;

Controlled Usage

javascript
import React, { useState } from 'react';
import MarkdownEditor from '@uiw/react-markdown-editor';

const mdStr = `# This is a H1  \n## This is a H2  \n###### This is a H6`;
export default function App() {
  const [markdown, setMarkdown] = useState(mdStr);
  return (
     setMarkdown(value)}
    />
  );
}

Only Markdown Preview

This markdown preview sub-component is a direct export @uiw/react-markdown-preview component, API documentation, please check @uiw/react-markdown-preview.

javascript
import React from 'react';
import MarkdownEditor from '@uiw/react-markdown-editor';

const mdStr = `# This is a H1  \n## This is a H2  \n###### This is a H6`;
function App() {
  return (
    
  );
}

export default App;

Custom Toolbars

…

Disable preview feature

javascript
import React from "react";
import MarkdownEditor from '@uiw/react-markdown-editor';

const Dome = () => (
  
);

export default Dome;

Support Nextjs

Use examples in nextjs.

bash
npm install next-remove-imports
npm install @uiw/react-markdown-editor
javascript
// next.config.js
const removeImports = require('next-remove-imports')();
module.exports = removeImports({});
javascript
import dynamic from 'next/dynamic';
import '@uiw/react-markdown-editor/markdown-editor.css';
import '@uiw/react-markdown-preview/markdown.css';

const MarkdownEditor = dynamic(
  () => import("@uiw/react-markdown-editor").then((mod) => mod.default),
  { ssr: false }
);

function HomePage() {
  return (
    

  );
}

export default HomePage;

Support dark-mode/night-mode

By default, the dark-mode is automatically switched according to the system. If you need to switch manually, just set the data-color-mode="dark" parameter for html Element.

xml
javascript
document.documentElement.setAttribute('data-color-mode', 'dark')
document.documentElement.setAttribute('data-color-mode', 'light')

Inherit custom color variables by adding .wmde-markdown-var selector.

javascript
const Demo = () => {
  return (
    

      
    
  )
}

Props

  • value (string) - the raw markdown that will be converted to html (required)
  • visible?: boolean - Shows a preview that will be converted to html.
  • toolbars?: ICommand[] | string[] - Tool display settings.
  • toolbarsMode?: ICommand[] | string[] - Tool display settings.
  • onChange?:function(editor: IInstance, data: CodeMirror.EditorChange, value: string) - called when a change is made
  • onBlur?: function(editor: IInstance, event: Event) - event occurs when an object loses focus
  • onPreviewMode?: (isHide: boolean) => void - Edit mode and preview mode switching event
  • previewProps - react-markdown options
…
…
…

Development

bash
npm run watch # Listen create type and .tsx files.
npm run start # Preview code example.

npm run doc

Related

  • @uiw/react-textarea-code-editor: A simple code editor with syntax highlighting.
  • @uiw/react-codemirror: CodeMirror component for React. @codemirror
  • @uiw/react-monacoeditor: Monaco Editor component for React.
  • @uiw/react-md-editor: A simple markdown editor with preview, implemented with React.js and TypeScript.
  • @uiw/react-markdown-preview: React component preview markdown text in web browser.

Contributors

As always, thanks to our amazing contributors!

Made with action-contributors.

License

Licensed under the MIT License.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptcodemirrorcodemirror-editoreditorhighlight

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架