A Markdown input for react-admin 5. It wraps @uiw/react-md-editor and binds it to the form with react-admin's useInput hook, so it behaves like any other input: validation, defaultValue, format/parse and helper text all work.
Dark mode follows the react-admin theme automatically:
npm install ra-input-markdown
# or
yarn add ra-input-markdownreact-admin (>= 5), react (>= 18), react-dom and @mui/material are peer dependencies; you already have them in a react-admin project.
import { Edit, SimpleForm, TextInput } from 'react-admin';
import { MarkdownInput } from 'ra-input-markdown';
export const PostEdit = () => (
<Edit>
<SimpleForm>
<TextInput source="title" fullWidth />
<MarkdownInput source="body" />
</SimpleForm>
</Edit>
);MarkdownInput accepts the usual react-admin input props (source, label, helperText, validate, defaultValue, format, parse, disabled, readOnly, ...) plus a few passthrough props for the underlying editor:
| Prop | Type | Description |
|---|---|---|
height |
number |
Editor height in pixels. |
minHeight |
number |
Minimum height when the dragbar is used. |
maxHeight |
number |
Maximum height when the dragbar is used. |
preview |
'live' | 'edit' | 'preview' |
Initial preview mode. Defaults to live. |
hideToolbar |
boolean |
Hide the formatting toolbar. |
visibleDragbar |
boolean |
Show the resize dragbar. |
commands |
ICommand[] |
Override the toolbar commands. |
extraCommands |
ICommand[] |
Extra commands (top-right of the toolbar). |
textareaProps |
object |
Props forwarded to the underlying textarea. |
<MarkdownInput source="body" height={400} preview="edit" />Version 2 is a rewrite for react-admin 5. The default export still works, but the named export is preferred:
// 1.x
import MarkdownInput from 'ra-input-markdown';
// 2.x (both work)
import { MarkdownInput } from 'ra-input-markdown';The editor changed from the unmaintained react-mde to @uiw/react-md-editor, which brings a live preview, dark mode and an actively maintained codebase. You no longer need to import any CSS yourself.
Apache-2.0

