Rich Text Editor

Tiptap editor with a keyboard-friendly toolbar, inline link field and character count.

Category
Forms
Access
Free with an account
Source
224 lines · one file
Added
4 Oct 2026

The decision inside it

No window.prompt for links

A prompt blocks the page, cannot be styled and loses the selection on some browsers. The link field opens in the toolbar and keeps the selection it applies to.

When to use it

Use Rich Text Editor for longer writing with formatting: comments, descriptions, notes, emails. It is built on Tiptap and gives you HTML on every change. Limit the toolbar with tools, and set maxLength to show a counter as the limit gets close. For plain text, Textarea is lighter.

Installation

How you get it

Paste this into Claude Code, Cursor, Codex or any coding agent. It installs the file and uses it as it is, instead of writing a new one.

Use Liro's Rich Text Editor for this.
Install it: npx shadcn@latest add @liro/rich-text-editor
(the @liro registry is set up in components.json, with LIRO_KEY in .env.local)
Import it from @/components/ui/rich-text-editor.
Do not rewrite or restyle it. Pass my data through its props
and keep its built-in states.

For the full brief with every prop and the mistakes assistants usually make, use Copy prompt above. Free components install through the @liro registry with your CLI token: see the Namespaced tab.

Usage

components/description-field.tsx
"use client";

import { RichTextEditor } from "@/components/ui/rich-text-editor";

export function DescriptionField({ onChange }: { onChange: (html: string) => void }) {
  return (
    <RichTextEditor
      label="Description"
      placeholder="Describe the change…"
      tools={["bold", "italic", "bullet", "ordered", "link"]}
      maxLength={2000}
      onChange={(html) => onChange(html)}
    />
  );
}

API reference

“Copy prompt” above puts a full brief on your clipboard, install command, dependencies, props, and the mistakes an assistant usually makes with this component.

Props

Read from the component’s own TypeScript interface when the site is built, so this table cannot drift from the file you install.

TypeNotes
defaultValuestring No–
onChange(html: string, editor: Editor) => void NoHTML on every change.
placeholderstring No–
maxLengthnumber No–
minHeightnumber NoMinimum height of the writing area in px. Default 140.
toolsArray<"heading" | "bold" | "italic" | "strike" | "code" | "bullet" | "ordered" | "quote" | "link" | "history"> NoWhich tools to show. Default: all.
editableboolean No–
labelstring NoAccessible name for the writing area.
classNamestring No–

Dependencies

npm packages

@tiptap/extensions@tiptap/react@tiptap/starter-kitclsxlucide-reacttailwind-merge

Liro foundations, installed alongside it

liro-themetooltip

Accessibility

  • Keyboard reachable throughout, in visual order
  • Focus trapped in overlays, Escape closes them
  • Focus returns to whatever opened it
  • Live regions announce what changed, not that something did
  • Honours prefers-reduced-motion

Responsive behavior

  • Sizes to its container, not the viewport
  • Usable from 320px up
  • Pointer-based interaction, so trackpad and touch both work
  • No hover-only affordances