export const title = "Text editor components" export const description = "Powerful and customizable React text editor components built for modern applications and websites. These text editors are built using TipTap and styled with Tailwind CSS." export const links = { tiptap: "https://tiptap.dev/docs", } import * as Demos from "@/components/base/text-editor/text-editor.demo.tsx";
## Installation You can add this Text editor component using our CLI or manually: ```bash npx untitledui@latest add text-editor ``` As our text editor component is built with [TipTap](https://tiptap.dev/docs), you'll need to install the dependencies: ```bash npm install @tiptap/core @tiptap/react @tiptap/pm @tiptap/starter-kit @tiptap/extension-text-style @tiptap/extension-image @tiptap/extension-placeholder @tiptap/extension-text-align @floating-ui/dom ``` Copy the files below into your project: Great! Now you can start using the text editor components in your project by just copy/pasting our examples below. ## Text editor examples Below are examples and variations of this text editor component: ### Default sm {{ tocOnly:true }}
### Default md {{ tocOnly:true }}
### Floating toolbar sm {{ tocOnly:true }}
### Floating toolbar md {{ tocOnly:true }}
### With tooltip {{ tocOnly:true }}
## API reference setContent(editor.getHTML())}` as in the examples. Set `isDisabled` to `true` to make the editor read-only.", }, { question: "How does the character limit work?", answer: "Set `limit` on `TextEditor.Root` and render `TextEditor.HintText` without children to show how many characters are left. The limit isn't enforced: users can keep typing, and the hint switches to the error style once they go over, so check the length before saving.", }, { question: "What is the difference between the simple and advanced toolbars?", answer: "`TextEditor.Toolbar` defaults to `type=\"simple\"`, with bold, italic, underline, text color, alignment and bullet list buttons. `type=\"advanced\"` adds font family and font size selects plus link, image and generate buttons. Set `floating` to give the toolbar a card style; the font selects are hidden when it floats, and `hideFontSize` hides only the size select.", }, { question: "How do I show formatting options when text is selected?", answer: "Add `TextEditor.Tooltip` inside `TextEditor.Root`. It uses Tiptap's bubble menu to show bold, italic, underline, alignment and link buttons next to the selection. Set `theme` to `\"dark\"` (default) or `\"light\"`.", }, { question: "Do I need to wire up the image and generate buttons?", answer: "Yes. The image button inserts the chosen file as a temporary local blob URL, so upload the file to your own storage and replace the URL before saving. The generate button has no handler, so connect it to your own logic.", }, ]} />