Rich text editor
A lightweight editor with markdown shortcuts, a floating toolbar, a slash menu, and HTML and markdown output.
npx shadcn@latest add @silicon-ui/rich-text-editorInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/rich-text-editorManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/rich-text-editor/rich-text-editor.tsx
- components/silicon-ui/rich-text-editor/rich-text-editor.module.css
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
| Prop | Type | Default |
|---|---|---|
valueControlled HTML. The editor only rewrites its content when this differs from what it last emitted. | string | — |
defaultValue | string | — |
defaultMarkdownInitial content as Markdown, used when no HTML value is given. | string | — |
onChange | (value: RichTextValue) => void | — |
onHistoryChangeReports whether undo and redo are available, for your own toolbar. | (state: { canUndo: boolean; canRedo: boolean }) => void | — |
placeholder | string | "Start writing" |
blockHintThe hint on an empty line while typing. | string | "Type / for blocks" |
readOnly | boolean | false |
autoFocus | boolean | false |
aria-label | string | — |
className | string | — |
style | CSSProperties | — |
Also accepts the props of HTMLAttributes.
Dependencies
- npm
- lucide-reactmotion
- Registry
- silicon-motion-tokens