Rich Text Editor

A composable rich text editor built on Tiptap, with a toolbar, bubble menu, character count and typeset content.

UIrich-text-editorView JSON

Typography is rendered inside a shadcn/typeset container. Nodes and marks are separate items: install the ones you compose into the rich text editor.

Preview

0 characters

Installation

Add the item with the shadcn CLI, or copy the source manually.

pnpm dlx shadcn@latest add litingyes/blocove/rich-text-editor

Requires a shadcn/ui project set up with Base UI primitives. Blocove is developed against the b0 preset, but it installs no base config or theme tokens: your own preset, fonts and colors stay in place.

Or install from the namespace after adding the registry: npx shadcn@latest add @blocove/rich-text-editor

This example also uses: rich-text-editor-headingrich-text-editor-code-blockrich-text-editor-boldrich-text-editor-italicrich-text-editor-underlinerich-text-editor-strikerich-text-editor-coderich-text-editor-link

pnpm dlx shadcn@latest add litingyes/blocove/rich-text-editor-heading litingyes/blocove/rich-text-editor-code-block litingyes/blocove/rich-text-editor-bold litingyes/blocove/rich-text-editor-italic litingyes/blocove/rich-text-editor-underline litingyes/blocove/rich-text-editor-strike litingyes/blocove/rich-text-editor-code litingyes/blocove/rich-text-editor-link
Typography is provided by shadcn/typeset. Copy typeset.css next to your stylesheet, import it after Tailwind and add the .typeset-docs preset. See the Rich text editor setup.

Usage

Install typeset
curl -o src/typeset.css https://ui.shadcn.com/typeset.css
Typeset setup
/* src/styles.css */@import "tailwindcss";@import "./typeset.css";@import "@fontsource-variable/inter";@import "@fontsource-variable/jetbrains-mono";
.typeset-docs {  --typeset-font-body: var(--font-inter);  --typeset-font-heading: var(--font-inter);  --typeset-font-mono: var(--font-jetbrains-mono);  --typeset-size: 16px;  --typeset-leading: 1.75;  --typeset-flow: 1.25em;}

API Reference

Props accepted by the exported components.

Editor

Root component. Registers the declared extensions and provides the editor context.

PropTypeDefault
valuestring-
defaultValuestring-
onChange(html: string) => void-
placeholderstring"Start writing…"
editablebooleantrue
autoFocusbooleanfalse
characterLimitnumber-
extensionsExtensions-
onReady(editor: Editor) => void-
classNamestring-
editorPropsEditorProps-
childrenReactNode-

EditorContent

Editable surface. Wraps the ProseMirror document in the typeset container.

PropTypeDefault
classNamestring-
typesetbooleantrue
...propsReact.ComponentProps<'div'>-

EditorToolbar

Toolbar with undo/redo, alignment and clear formatting. Children are extension controls.

PropTypeDefault
classNamestring-
childrenReactNode-

EditorToolbarButton

Toolbar control with a tooltip and an optional keyboard shortcut. Used by every extension item.

PropTypeDefault
labelstring-
shortcutstring-
pressedboolean-
onPressedChange(pressed: boolean) => void-
onClick() => void-
disabledbooleanfalse
classNamestring-
childrenReactNode-

EditorBubbleMenu

Floating menu shown above a text selection. Render mark controls as children.

PropTypeDefault
classNamestring-
childrenReactNode-

EditorFloatingMenu

Menu anchored to the block holding the caret. It only shows while that block is empty, which is where an insert affordance belongs.

PropTypeDefault
classNamestring-
childrenReactNode-

EditorCharacterCount

Live character and word count for the current document.

PropTypeDefault
classNamestring-
format"characters" | "words" | "both""characters"

defineExtensionComponent

Declares a Tiptap extension as a component that the Editor collects from its children.

PropTypeDefault
namestring-
extension(props) => Extensions-
returnsExtensionComponent-