Editor

Rich text editor with formatting toolbar, auto-save, and word count

Setup

import { Editor } from '@fragments-sdk/ui';

Examples

Default

Editor with default toolbar and status bar

Loading preview...

With Auto-Save and Publish

Full compound usage with custom toolbar, auto-save indicator, and publish button

Loading preview...

Minimal

Editor with subset of formats

Loading preview...

Disabled

Non-interactive editor with content

Loading preview...

Read Only

Visible content, non-editable

Loading preview...

Custom Toolbar

Compound usage with custom toolbar layout and separator

Loading preview...

Full Formatting

All format options including headings, blockquote, ordered list, undo/redo

Loading preview...

With Character Limit

Editor with maxLength showing character count indicator with warning and error states

Loading preview...

Small Size

Compact editor with sm size preset (120px min-height)

Loading preview...

Props

PropTypeDefaultDescription
childrennodeNot set
valuestringNot setControlled editor value
defaultValuestringDefault value for uncontrolled usage
onValueChangefunctionNot setCalled when content changes
placeholderstringStart typing...Placeholder text shown when empty
disabledbooleanfalseDisable the editor
readOnlybooleanfalseMake the editor read-only
formatsarray["bold", "italic", "strikethrough", "link", "code", "bulletList"]Which format buttons to show in the toolbar
toolbarbooleantrueShow default toolbar
statusBarbooleantrueShow default status bar with word/character counts
onAutoSavefunctionNot setAuto-save callback, called at autoSaveInterval (may be async)
autoSaveIntervalnumber30000Auto-save interval in milliseconds
sizeenumsmmdlgmdEditor size preset: "sm" (120px), "md" (200px), or "lg" (400px)
maxLengthnumberNot setMaximum character count. Shows counter in status bar with warning (90%) and error (over limit) states
toolbarIconsobjectNot setOptional toolbar icon overrides keyed by format/action (e.g. bold, italic, undo). Values can be React nodes or render functions.

Usage Guidelines

When to use

  • Building blog post or article editors
  • Need rich text editing with formatting controls
  • Content management with auto-save and word count
  • Markdown or WYSIWYG editing interfaces

When not to use

  • Simple single-line text input (use Input)
  • Plain multi-line without formatting (use Textarea)
  • Chat/AI prompt input (use Prompt)
  • Code editing (use CodeBlock)

Best practices

  • Use compound pattern for custom toolbar layouts
  • Install @tiptap/react, @tiptap/starter-kit, and @tiptap/extension-link for rich text mode
  • Falls back to a markdown-aware textarea when TipTap is not installed
  • Use onAutoSave for periodic content persistence
  • onAutoSave may return a Promise; save status updates after the async save resolves/rejects
  • Use size prop (sm/md/lg) to control editor height
  • Use maxLength to show character limit with visual warning states
  • New formats (headings, blockquote, orderedList, undo, redo) are opt-in via the formats prop
  • Use toolbarIcons to swap in icons from any icon package without changing toolbar button labels or accessibility behavior
Accessibility
  • Toolbar has role="toolbar" with aria-label
  • Format buttons use aria-pressed to indicate active state
  • Action buttons (undo/redo) omit aria-pressed since they are not toggles
  • Status indicator uses aria-live="polite" for save status announcements
  • Keyboard shortcuts match standard text editor conventions (Ctrl+B, Ctrl+I, etc.)
  • Global shortcuts (e.g., Sidebar Ctrl+B) automatically yield when focus is inside the Editor
  • Focus ring appears on the editor container when any child element is focused