Component API

<editable-text>

Open live example

Jira/GitHub-style click-to-edit text: a display span that turns into an
<input> (or auto-growing <textarea> when multiline) on click. The
input/textarea inherits the host's font, so a title wrapped in an <h1>
edits at title size.

Install

import "@f-ewald/components/editable-text.js";

Usage

<editable-text value="Write the quarterly report" label="Title"></editable-text>
<editable-text multiline placeholder="Add a description…" label="Description"></editable-text>

Attributes / properties

PropertyAttributeTypeDefaultDescription
valuevaluestring""Current text.
multilinemultilinebooleanfalsefalse renders an <input>, true an auto-growing <textarea>.
placeholderplaceholderstring""Muted placeholder text shown when value is empty, and as the input's placeholder.
readonlyreadonlybooleanfalseDisables entering edit mode.
labellabelstring""aria-label applied to the input/textarea.

Events

EventDescription
changeFired with { value: string } when the committed value differs from the previous one.

Slots

None.

CSS custom properties

Custom property
--ui-border
--ui-focus-ring
--ui-primary
--ui-radius-sm
--ui-surface
--ui-surface-muted
--ui-text-muted