Ballmac UI home

Rich Text Editor

A rich text editor on Tiptap: headings, bold, lists, checklists, quotes, code and links, with a toolbar you drive by keyboard, a slash menu for blocks, a link popover, a character limit and HTML output.

Installation

$ pnpm dlx shadcn@latest add @ballmac/rich-text-editor

Usage

import { RichTextEditor, cleanUrl } from "@/components/ballmac/rich-text-editor"

The full example is in the Code tab above.

Examples

Comment box with a limit

In a form

About you

Checklist

Disabled

Loading

Could not load

API reference

PropTypeDefault
label*

What the editor is for, read by screen readers: "Message".

string—
value

The content, as HTML, when you hold it in state. Pair with `onChange`.

string—
defaultValue

The content to start with, when the editor holds it.

string—
onChange

Called with the HTML when the content changes. Clean it before you store or show it to others.

(html: string, editor: Editor) => void—
placeholderstring—
features

Which tools to offer. Leave out `slash` to turn off the "/" menu.

RichTextFeature[]—
disabledboolean—
characterLimit

Stop at this many characters, and show the count.

number—
showCount

Show the word and character count under the editor.

boolean—
invalidboolean—
description

Hint or error shown under the editor and linked to it.

React.ReactNode—
minHeightnumber—
maxHeightnumber—
autoFocus

Focus the editor when it mounts.

boolean—
linksInNewTab

Opens links in a new tab. Off by default.

boolean—
editorRef

Hands you the Tiptap editor, for anything this does not cover.

React.Ref<Editor | null>—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
TabThe toolbar is one tab stop, and the editor is the next; Escape then Tab leaves the editor
Arrow keys / Home / End (toolbar)Move between tools; they swap in right-to-left
Ctrl or Cmd + B, I, U, KBold, italic, underline and the link popover; markdown shortcuts like ## and - work as you type
/Opens the block menu; Up and Down choose, Enter inserts, Escape closes, and the highlighted block is announced
Screen readersThe editor is a labelled multiline textbox; tools are toggle buttons with aria-pressed; invalid and disabled are set on the textbox

Quality scorecard

8/8

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 7 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules). Not part of the pass mark: some controls are smaller than the 24 px WCAG 2.2 target size (rich-text-editor-checklist).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    Every endless animation stops when the visitor asks for less motion.

  • Passed: Right to left

    Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (7% of elements off the mirror, limit 15%).

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Passed: Keyboard

    11 tab stops, each showing a visible change when it takes focus. 5 documented keys.

  • Passed: Loading, empty and error

    Ships loading, error, disabled states, each with an example.

  • Passed: Automated tests

    Covered by rich-text-editor.test.tsx.

  • For information: Footprint

    9.6 KB of source (gzip) in 1 file. Installs @tiptap/core, @tiptap/react, @tiptap/pm, @tiptap/starter-kit and 5 more.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Use with AI

Hold the HTML in state: <RichTextEditor label value={html} onChange={setHtml} />. Pick tools with features, add characterLimit and showCount, and mark invalid with description. Sanitize the HTML before you store or show it. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Rich Text Editor (@ballmac/rich-text-editor) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Comments, descriptions, notes and release notes people format
  • Content that is stored as HTML and shown elsewhere
  • Forms that need a labelled, validated, accessible editor

Not for

  • Plain multi-line text; use textarea
  • Code editing with syntax highlighting; use a code editor
  • Real-time collaboration, comments in the margin or tables out of the box; build on the Tiptap editor from editorRef

Registry JSON: https://ui.ballmac.com/r/rich-text-editor.json

Credits

Based on Tiptap, adapted by Ballmac. Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.