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
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add rich-text-editorOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { RichTextEditor } from "@/components/ui/rich-text-editor"; <RichTextEditor defaultValue="<p>Hello</p>" />Source code
rich-text-editor.tsx + 1 helperZero 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 />| Prop | Type | Description |
|---|---|---|
| value | string | Controlled HTML value. |
| defaultValue | string | Uncontrolled initial HTML value. |
| onValueChange | (html: string) => void | Callback on value change. |
| placeholder | string | Placeholder text. |
| disabled | boolean | Disable editor. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |