Skip to content

Rich Editor

MessagingMIT
View in Storybook

Tiptap-based WYSIWYG editor with full toolbar, bubble menu, slash commands, tables, and markdown shortcuts.

bun add @otfdashkit/ui

Preview

Rich Editor

Code

import { useState } from 'react'
import { RichEditor } from '@otfdashkit/ui'

export function Example() {
  const [html, setHtml] = useState('')
  return (
    <div className="mx-auto w-full max-w-2xl space-y-3">
      <RichEditor onChange={setHtml} />
      <details className="text-xs text-[hsl(var(--muted-foreground))]">
        <summary className="cursor-pointer select-none">View HTML output</summary>
        <pre className="mt-2 overflow-x-auto rounded-md bg-[hsl(var(--muted))] p-3 font-mono text-[11px]">
          {html || '<empty>'}
        </pre>
      </details>
    </div>
  )
}

Free with the SDK. This block ships in @otfdashkit/ui under the MIT license.

Props

Props declared in the RichEditor source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
defaultValuestring | (readonly string[] & string)Initial uncontrolled HTML content.
editablebooleantrueDefault true. When false the content is read-only and no toolbar is shown.
maxLengthnumberOptional character cap. Shows a counter and clamps content via onUpdate.
onChange(html: string) => voidFired (debounced 100ms) when the editor's HTML changes.
placeholderstring'Write something...'Placeholder shown when the document is empty.
toolbar'full' | 'minimal' | 'bubble''full'Toolbar layout. Default 'full'.
valuestringControlled HTML content.