Rich Text Field
The frame around a rich text editor: a label, a toolbar of 28 px formatting buttons over a divider, and the text with the field's edge and focus. The editor engine stays in the app (the CRM's Tiptap); paragraphs, lists and links inside take the field's type.
BetaReady to use. Its API can still change in a minor release; the changelog says when.
import { RichTextButton, RichTextField, RichTextSeparator } from "@leap-crm/design-system";With a toolbar
Click into the text for the focus edge. Tab reaches the toolbar once; arrow keys move along it. A pressed button shows the pressed fill. In the CRM the children are Tiptap's EditorContent, given the editor props.
Prefers email. Settlement checklist is in the matter folder.
- Call the vendor’s solicitor
- Send the costs agreement
Invalid
Too short.
What the examples share
The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.
import { Bold, Italic, Link, List, ListOrdered } from "lucide-react";
import { useState } from "react";
import { RichTextButton, RichTextField, RichTextSeparator } from "@leap-crm/design-system";
function Formatting() {
const [on, setOn] = useState<Record<string, boolean>>({ list: true });
const toggle = (key: string) =>
setOn(current => ({ ...current, [key]: !current[key] }));
return (
<>
<RichTextButton
icon={<Bold />}
label="Bold"
shortcut="mod+b"
pressed={on.bold ?? false}
onClick={() => toggle("bold")}
/>
<RichTextButton
icon={<Italic />}
label="Italic"
shortcut="mod+i"
pressed={on.italic ?? false}
onClick={() => toggle("italic")}
/>
<RichTextButton
icon={<List />}
label="Bulleted list"
pressed={on.list ?? false}
onClick={() => toggle("list")}
/>
<RichTextButton
icon={<ListOrdered />}
label="Numbered list"
pressed={on.numbered ?? false}
onClick={() => toggle("numbered")}
/>
<RichTextSeparator />
<RichTextButton icon={<Link />} label="Link" shortcut="mod+k" />
</>
);
}
const sample = (
<>
<p>
Prefers email. <a href="/rich-text-field">Settlement checklist</a> is in
the matter folder.
</p>
<ul>
<li>Call the vendor’s solicitor</li>
<li>Send the costs agreement</li>
</ul>
</>
);Best practices
When to use it, and the rules that apply in particular places.
| Guidance | Practice |
|---|---|
| Do | Use it when the reader needs the formatting, like a note with a list of next steps or an email body with links. Use Textarea for plain text. |
| Do | Pass the editor as a function child and spread the props it receives onto the editable element, so label names the editor for screen readers. |
| Do | Give every RichTextButton a label, and a shortcut where one exists, like mod+b for bold. The label is its name and its tooltip. |
| Do | Separate groups of buttons with RichTextSeparator, like text styles apart from lists. |
| Don't | Set invalid with nothing else. It only turns the edge red, so add text under the field that says what to do, like "Please enter a note". |
| Don't | Put a separate Label above it. Use label, which is wired to the editor. |
Props
RichTextField
| Prop | Type | Default | Description |
|---|---|---|---|
| label | ReactNode | — | Names the editor. |
| toolbar | ReactNode | — | The formatting buttons: RichTextButton and RichTextSeparator. |
| toolbarLabel | string | "Formatting" | Names the toolbar for screen readers. |
| invalid | boolean | false | Draws the field invalid. |
| className | string | — | Classes added to the root element, merged with its own. Tokens only. |
| children * | ReactNode | ((props: EditorProps) => ReactNode) | — | The editor. A function receives the props that name it. |
RichTextButton
| Prop | Type | Default | Description |
|---|---|---|---|
| icon * | ReactNode | — | The 14 px icon. |
RichTextSeparator
No props of its own.
Keyboard
The keys it answers to. Tab moves between components, arrows move within them.
| Keys | What they do |
|---|---|
| Tab | Lands on the toolbar once, and Tab again leaves it. |
| ArrowRightArrowLeft | Move between the toolbar's buttons. |
| EnterSpace | Press the focused toolbar button. |





