A full-featured text editor with formatting toolbar. Supports Default, Input, and Text Selected modes, expandable layout, and mobile.
Loading demo: rich-text-editor-real-world
npx sdaia-ui@latest add rich-text-editor
import { RichTextEditor } from '@/components/ui/RichTextEditor';<RichTextEditor type="default" />Rich text editor with the full formatting toolbar.
Loading demo: rich-text-editor-default
Rich text editor in input mode for inline editing.
Loading demo: rich-text-editor-input
Editor with text selected, revealing the inline formatting options.
Loading demo: rich-text-editor-text-selected
Rich text editor adapted for mobile screens.
Loading demo: rich-text-editor-mobile
Props for the RichTextEditor component.
Prop | Type | Default | Required |
|---|---|---|---|
type | 'default' | 'text-selected' | 'input' | 'default' | optional |
mobile | boolean | false | optional |
expand | boolean | false | optional |
isBold | boolean | false | optional |
isItalic | boolean | false | optional |
isUnderline | boolean | false | optional |
alignment | 'left' | 'center' | 'right' | - | optional |
textStyle | string | - | optional |
textStyleOptions | string[] | - | optional |
fontSize | string | - | optional |
fontSizeOptions | string[] | - | optional |
onTextStyleChange | (value: string) => void | - | optional |
onFontSizeChange | (value: string) => void | - | optional |
onUndo | () => void | - | optional |
onRedo | () => void | - | optional |
onBold | () => void | - | optional |
onItalic | () => void | - | optional |
onUnderline | () => void | - | optional |
onAlign | (alignment: TextAlignment) => void | - | optional |
onColor | () => void | - | optional |
onLink | () => void | - | optional |
onImage | () => void | - | optional |
onAI | () => void | - | optional |
value | string | "" | optional |
placeholder | string | 'You can write here…' | optional |
onChange | (value: string) => void | — | optional |
onAddContent | () => void | - | optional |
onFormatText | () => void | - | optional |
onEmoji | () => void | - | optional |
onMention | () => void | - | optional |
labels | Partial<RichTextEditorLabels> | English strings | optional |
dir | "ltr" | "rtl" | — | optional |
How this component behaves at the three system breakpoints. Spacing and type tokens switch automatically at 768px and 1280px.
| Screen | Behavior |
|---|---|
| Desktop (1280px and up) | Full width of its container. The toolbar sits in one row above the content. |
| Tablet (768–1279px) | Same layout; toolbar groups wrap onto a second row when they don't fit. |
| Phone (under 768px) | The toolbar wraps. Set mobile for the two-row toolbar with collapsed format groups; it does not switch on its own. Menus are never wider than the screen. |