Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic
Forms Form-associated

Editor <pm-editor>

Rich-text editor for short formatted content: comments, descriptions, notes. Form-associated; submits clean HTML.

Full screen

Props

<script type="module"> import '@prismora/css'; import '@prismora/elements/editor'; </script> <pm-editor label="Description" name="description" placeholder="Describe the change…" hint="Select text to format it. Ctrl+K adds a link." value="<p>Ship the <strong>new charts</strong> on Monday.</p><ul><li>Update the docs</li><li>Tell support</li></ul>" style="inline-size: min(100%, 34rem)"></pm-editor>

States

Each state is one attribute.

Disabled
Read-only
Required
Error

Overview

Supports bold, italic, underline, headings, lists, quotes, code and links, with the usual keyboard shortcuts. Pasted and assigned content is reduced to those tags, so the value never contains scripts, styles or unknown markup. Sanitise again on the server before storing or showing it: the browser is not a trust boundary.

Attributes

AttributeTypeDefaultDescription
labelstring—Visible label (required for accessibility).
valuestring—Initial HTML.
placeholderstring—Shown while empty.
hintstring—Help text under the editor.
errorstring—Custom error message. Setting it marks the field invalid.
requiredboolean—The form cannot be submitted while the editor is empty.
disabledboolean—Not editable and not submitted.
readonlyboolean—Not editable, still submitted.
toolbarstring—Tools to show, space-separated, with | for a divider: bold italic underline strike h2 h3 bullet number quote code link clear undo redo.
maxlengthnumber—Longest allowed text, in characters.
namestring—Form field name.

Also accepts the contextual attributes tone, surface, radius, density, motion, elevation. They are inherited from ancestors' data-* attributes.

Events

EventReact / Svelte propDescription
pm-inputonPmInputThe content changed.
pm-changeonPmChangeThe content changed and the editor lost focus.

Methods

checkValidity(), reportValidity(), focus()