Componenteditors2.49 KB gzipZero dependencies

Rich Text Editor

Minimal contentEditable editor with toolbar (bold, italic, underline, lists, links, quote, code) and word/char counter.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add rich-text-editor

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { RichTextEditor } from "@/components/ui/rich-text-editor"; <RichTextEditor defaultValue="<p>Hello</p>" />

Source code

rich-text-editor.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxrich-text-editor.tsx339 lines
"use client"; import * as React from "react";import { cn, isSafeUrl } from "./lib/utils"; const ALLOWED_TAGS = new Set([  "B", "STRONG", "I", "EM", "U", "S", "STRIKE",  "P", "BR", "DIV", "SPAN", "H1", "H2", "H3", "H4",  "UL", "OL", "LI", "BLOCKQUOTE", "PRE", "CODE", "A",]); function appendSanitizedNodes(source: Node, target: Node, doc: Document): void {  for (const child of Array.from(source.childNodes)) {    if (child.nodeType === 3) {      target.appendChild(doc.createTextNode(child.textContent ?? ""));      continue;    }    if (child.nodeType !== 1) continue;

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { RichTextEditor } from "@/components/ui/rich-text-editor"; <RichTextEditor />
PropTypeDescription
valuestringControlled HTML value.
defaultValuestringUncontrolled initial HTML value.
onValueChange(html: string) => voidCallback on value change.
placeholderstringPlaceholder text.
disabledbooleanDisable editor.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.