Editors
Tiptap
A rich text editor built on Tiptap 3, with a toolbar in the style of the other components, as a form field: label, help text and validation error around it, and its content saved as HTML in a hidden field. The Tiptap modules are loaded on demand, only those the toolbar needs.
Nothing to show
A "Body" label over a bordered box with a toolbar: bold, italic, underline, strike, headings 1 to 3, text and highlight colors, font size, sub and superscript, alignment, link, lists, image and video, table, quote, and code. Each change is saved as HTML in a hidden field named body, sent with the form.
Bound to Livewire #
The editor opens with the HTML of $body, with only the formatting, heading, list and link buttons, and each change sets the property. Setting $body on the server replaces the content shown.
<p>Hello <strong>world</strong></p>
Nothing to show
Images #
The image and video buttons upload the chosen file to the server and insert it by URL; inserted images can be resized by dragging, keeping their proportions. :upload="false" keeps them inline, as data URLs.
Nothing to show
Read-only #
readonly and disabled lock the editor and its toolbar.
Nothing to show
Events #
rendered fires on the tag when the editor is ready, with the Tiptap instance in $event.detail.editor, so buttons outside can run its commands (unwrapped with Alpine.raw, as Tiptap breaks inside a reactive proxy).
Nothing to show
Customization #
editor: reaches the editor box, toolbar: the toolbar and toolbar-button-<command>: a single button, such as the bold one here.
Nothing to show
Reference
tk:tiptap
| Prop | Type | Default | Description |
|---|---|---|---|
toolbar |
string | all groups | The toolbar groups, separated by spaces: text, heading, color, size, script, align, link, list, media, table, quote, code. full turns on all of them, none hides the toolbar. |
upload |
array | false | on | How images and videos are uploaded, as on tk:quill: disk, directory, types, maxSize, guest, url. false keeps them inline. |
version |
string | 3.30.3 |
The Tiptap version loaded from esm.sh. |
options |
array | [] |
Tiptap editor options, merged over the component's. |
scripts |
array | [] |
URLs of extra ES modules to load, for extensions. The loaded modules are extraModules in data-options: data-options="{ extensions: [extraModules[0].default] }". |
styles |
array | [] |
URLs of stylesheets. |
Also accepts the field props and the field control props. wire:model and x-model bind the HTML as a string. data-options is an attribute: a JavaScript expression merged over the options, for functions and extensions. Its extensions are added to the toolbar's, and its onUpdate and onTransaction run after the component's, so the value keeps syncing.
Slots
| Slot | Description |
|---|---|
| default | The initial HTML, in place of value. |
Events
| Event | Detail | When |
|---|---|---|
rendered |
{ editor }, the Tiptap instance |
The editor is ready. Dispatched on the hidden field; does not bubble. |
upload-failed |
{ error, file, type, message } |
An image or video could not be uploaded. Dispatched on the hidden field; bubbles and is cancelable. Unless preventDefault() is called, message is shown in a toast, or in window.alert when the page has no toast area. |
started, completed, failed |
Tiptap starts loading, is ready, or could not be loaded or started. Dispatched on the editor box (listen with the editor: prefix); do not bubble. |
Prefixes
| Prefix | Goes to |
|---|---|
editor: |
The editor box, around the toolbar and the editing area. |
toolbar: |
The toolbar. |
toolbar-button: |
Every toolbar button, the color and size buttons included. |
toolbar-button-<command>: |
One button: bold, italic, underline, strike, heading1 to heading3, subscript, superscript, alignLeft, alignCenter, alignRight, alignJustify, link, image, video, table, bulletList, orderedList, blockquote, code, codeBlock. |
toolbar-button-text-color:, toolbar-button-highlight-color: |
The two color pickers. |
toolbar-size:, toolbar-button-size: |
The font size dropdown and its button. |
toolbar-size-menu:, toolbar-size-menu-item:, toolbar-size-menu-item-reset:, toolbar-size-menu-separator: |
The font size menu, its items, its Reset item and the line above it. |
toolbar-separator: |
The lines between the button groups. |
Events
Nothing to show
Customization
Classes on the tag go to the field control; other attributes go to the hidden field. Besides the prefixes of the field props (listed in the Reference above).
Nothing to show
Accessibility
The editing area is a role="textbox" named by the label and described by the help text and the error, with aria-invalid when the field is invalid; both follow Livewire validation. The toolbar is a WAI-ARIA toolbar named "Formatting" (translated), with translated button names and one button in the tab order at a time.
| Key | Action |
|---|---|
| Tab | Moves between the toolbar and the editing area. |
| Arrow Right / Arrow Left | Moves between the toolbar buttons, wrapping around at the ends (reversed in right-to-left pages). |
| Home / End | Moves to the first or the last toolbar button. |
| Ctrl/Cmd+B, I, U | Bold, italic, underline. |
Behavior notes
- Tiptap and its extensions are imported from esm.sh at the chosen
version, only for the groups in the toolbar. disabledandreadonlylock the editor and the toolbar, also when toggled later.- Inside a Livewire component, when the field is bound (
wire:model, or the automatic binding fromname),valueand the slot are ignored: the bound property is the value. - The HTML the field sends comes from the browser and can hold anything: sanitize it on the server before showing it to other users.