Early bird: 30% off Dashral ProSee pricing

Dashral

Rich Text EditorNew

Formatted text with a toolbar, keyboard shortcuts and markdown as you type; its value is HTML for forms.

$ pnpm dlx shadcn@latest add @dashral/rich-text-editor

Shown to everyone on the changelog page.

Installation

$ pnpm dlx shadcn@latest add @dashral/rich-text-editor

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Or by its full URL: https://dashral.com/r/rich-text-editor.json

When to use

  • Formatted text people write: a description, release notes, a reply with lists and links.
  • In a form: its value is HTML, sent under name, with a label, hint and error like any field.

When not to use

  • Plain text, even long: Textarea (lighter, no HTML to store).
  • A chat message to an assistant: Prompt Composer.
  • Showing HTML you already have: Prose.

Usage

The HTML kept in state as it's typed, and sent with the form under name.

example.tsx
"use client"

import { useState } from "react"
import { Button } from "@/components/dashral/button"
import { RichTextEditor } from "@/components/dashral/rich-text-editor"

export default function JobDescription() {
  const [html, setHtml] = useState("")

  return (
    <form action="/jobs" method="post" className="grid max-w-xl gap-4">
      <RichTextEditor
        label="Job description"
        name="description"
        placeholder="The role, the team, what a good first month looks like…"
        maxLength={2000}
        value={html}
        onValueChange={setHtml}
      />
      <Button type="submit" className="w-fit" disabled={!html}>
        Post job
      </Button>
    </form>
  )
}

Using the npm package? Import from @dashral/ui/components/rich-text-editor instead, here and in the examples; the rest is the same.

Examples

In a form

name sends the HTML; maxLength stops at the limit, showCount counts all the way.

600 characters left

Write and preview

value and onValueChange keep the HTML in your state; Prose shows it as readers will.

Preview

Welcome aboard

Your workspace is ready. Start with the guide, then invite your team.

Tip: type ## for a heading or - for a list.

Comment box

toolbar picks the tools; actions adds your own at the end.

API reference

RichTextEditor

Built on Tiptap (open-source extensions only). Other props go on the box around the toolbar and the text.

PropTypeDefault
labelReactNode

Shown above, linked to the control.

—
descriptionReactNode

A hint under the control.

—
errorboolean | ReactNode

true shows the error style; a message also shows under the control.

—
labelActionReactNode

At the end of the label's row, e.g. a “Forgot password?” link or the current value.

—
withAsteriskboolean

Marks the label with an asterisk, e.g. alongside required.

false
valuestring

The content as HTML, with onValueChange: it controls the editor. "" is empty.

—
defaultValuestring | JSONContent

The starting content, as HTML or Tiptap JSON, when value isn't used.

—
onValueChange(html: string, editor: Editor) => void

Called as the content changes, with the HTML ("" when empty). editor.getJSON() and editor.getText() give the other forms.

—
namestring

Sends the HTML with a form, in a hidden input of this name.

—
placeholderstring

Shown while it's empty.

—
maxLengthnumber

Stops typing and pasting past this many characters; the count shows in the last tenth.

—
showCountboolean

Always shows the character count ("120/500" with maxLength).

false
toolbarRichTextTool[] | false

The tools, in order, "|" for a divider; undo and redo at the end sit at the far side. false hides it (shortcuts and markdown still work).

every tool
headings(1 | 2 | 3 | 4)[]

The heading levels in the text style menu.

[1, 2, 3]
actionsReactNode

Controls of your own at the end of the toolbar, e.g. an icon Button.

—
readOnlyboolean

Shows the content without letting it change; the toolbar hides.

false
disabled / requiredboolean

As on other controls; required marks it aria-required (check the value on submit).

—
autoFocusboolean

Puts the cursor at the end once it's ready.

false
extensionsAnyExtension[]

More Tiptap extensions, after the built-in ones. Changing the list remakes the editor.

—
editorRefRef<Editor | null>

The Tiptap editor once it exists, for commands of your own: editor.chain().focus().insertContent("@").run().

—
classNames{ root, label, description, error, editor, toolbar, content }

Classes for each part.

—
classNamestring

Extra classes, merged with cn() so yours win.

—

RichTextTool

= "heading" | "bold" | "italic" | "underline" | "strike" | "code" | "bulletList" | "orderedList" | "blockquote" | "link" | "undo" | "redo" | "|"

Keyboard

KeysAction
⌘ Bor⌘ Ior⌘ UBold, italic, underline (Ctrl elsewhere)
⌘ ⇧ Sor⌘ EStrikethrough, inline code
⌘ ⌥ 0–4Text, or a heading of that level
⌘ ⇧ 8or⌘ ⇧ 7or⌘ ⇧ BBulleted list, numbered list, quote
⌘ KAdd or edit a link
⌘ Zor⌘ ⇧ ZUndo, redo
Tabor⇧ TabIn a list: indent or outdent the item
Alt F10From the text to the toolbar
←or→, HomeorEndAlong the toolbar
EscClose the link panel or the text style menu

Accessibility

  • With label, description or error, the id, aria-describedby and aria-invalid are wired up for you.
  • The text is a multi-line textbox named by its label (aria-labelledby), so a click on the label writes in it too; give aria-label when there's no label.
  • The toolbar is a toolbar (one Tab stop, arrows move along it). Each tool has a name and says whether it's on (aria-pressed); the text style button says the current style.
  • Markdown as you type: ## and a space for a heading, - or 1. for a list, > for a quote, **text** for bold.
  • Links take http, https, mailto and tel only; example.com becomes https://example.com.
  • Its words come from the kit's messages, so a LocaleProvider translates them.

Motion

  • The menu, link panel and tooltips use the kit's quick fade and zoom; the count fades in near the limit.

Blocks and screens

Sections and whole screens ready to drop in: the ones built with Rich Text Editor or for the same job first, then more from Dashral Pro. Free ones come with their code; Pro ones come with Dashral Pro.

  • Billing settingsPro

    The plan with dialogs to change or cancel it, what this period costs so far and where it's heading against the budget and alerts, usage with what going past each limit costs, spend alerts by email or Slack, the card on file and invoices. On motion.

  • Developer settingsPro

    API keys for live and test, a new key's secret shown once as its characters settle, revoking behind a hold, and webhooks: each endpoint with its recent deliveries, events and signing secret, a test event that lands in the log, deliveries opened with their payload and retried in place. On motion.

  • Workspace brandingPro

    The workspace's name, logo, cover and colour, previewed live in the sidebar, the sign-in page, emails and invoices.