Skip to content

Editable ​

Click/Enter/Space enters edit mode; Enter submits, Esc cancels, and empty-value submission is non-destructive by default. Supports multiline editing, icon triggering, controlled editing state, and the four-way submit-mode matrix.

Basic Usage ​

Click to edit

Click the text (or press Enter/Space when focused) to enter edit mode; Enter submits, Esc reverts.

Placeholder ​

Empty value placeholder

placeholder is shown when the value is empty.

Submit Mode Matrix ​

submit-on-enter=false (button/blur only)

submit-on-blur=false (no accidental submits)

Both off (explicit buttons only)

submit-on-enter (default true) and submit-on-blur (default true) combine into four submit modes: both (default) / Enter only / blur only / buttons only.

Controlled Editing ​

editing attribute programmatic control

Enter/exit editing

default-editing starts in edit mode (new-item scenario)

  • Setting the editing attribute enters edit mode; removing it exits through the cancel path (non-destructive, dispatches oas-cancel)
  • Internal enter/exit reflects the editing attribute; hosts can watch the attribute or the oas-editing event (detail: { editing: boolean }, dispatched once on enter and once on exit)

Multiline Editing ​

multiline (Ctrl/⌘+Enter submits)

With multiline the edit mode renders a textarea: Enter inserts a newline, Ctrl/⌘ + Enter submits, Esc cancels; the height auto-grows with content (minimum one line). Ctrl+Enter during an IME composition (candidate confirmation) does not submit accidentally.

Icon Triggering ​

trigger=icon (pencil button, accidental-click safe)

trigger="text" (default) edits on text click; with trigger="icon" the text is plain display and the trailing pencil button carries the interaction (focusable; Enter/Space/click enters edit); with trigger="dblclick" double-click enters edit (single click doesn't trigger, so text stays selectable; Enter/Space while focused enters edit as a keyboard fallback). Useful when text clicks may conflict with page behavior.

trigger=dblclick (double-click to edit)

Custom Display ​

template[slot=display] icon + text

template[slot="display"] clones the display content: [data-display-value] binds the current value and [data-display-placeholder] binds the placeholder text; the default falls back to plain text.

Custom Action Icons ​

template[slot=ok-icon] / [slot=cancel-icon]

Empty-Value Semantics ​

allow-empty (allow clearing)

By default an empty submission reverts to the old value and dispatches oas-cancel (non-destructive); with allow-empty an empty value submits as an empty string and dispatches oas-change (the "clear/reset" scenario).

Size / Status / Readonly ​

size variants

status=error

readonly (focusable, readable, not editable)

readonly differs from disabled: it keeps normal text color, stays focusable and copyable, and only blocks entering edit mode (aria-readonly).

maxlength ​

Length limit

Disabled ​

disabled

Events ​

Submit/cancel/editing-state events

Listen to oas-change (submit), oas-cancel (cancel/empty submit), and oas-editing (editing-state toggle, detail: { editing }):

Non-Text Inplace Editing (Composition Pattern) ​

For "click to swap in arbitrary content" (tables, images), no extra component is needed — display slot + host-side toggling replaces it:

Host v-if toggle + display slot composition

ADisplay: avatar + name (arbitrary content)Edit

The host toggles between display and edit blocks of arbitrary content with v-if / hidden (a few lines of boilerplate); for text scenarios use oas-editable directly (its display slot + controlled editing encapsulate the same mechanism).

Capability Overview (page notes) ​

  • submit-on-blur: default true (blur submits, the existing behavior); false completes the four-way submit matrix
  • editing / default-editing: controlled / initial editing state (exits always go through the submit/cancel paths)
  • multiline: multiline editing — Ctrl/⌘+Enter submits, Enter inserts a newline, auto-growing height
  • trigger: text | icon | dblclick (click text / pencil button / double-click to edit, all configurable)
  • allow-empty: allow submitting an empty string (non-destructive revert by default)
  • size / status / readonly: three sizes, validation status, readonly
  • Slots: template[slot="display"] (data-display-value / data-display-placeholder bindings), ok-icon / cancel-icon
  • Events: oas-editing { editing } (existing oas-change / oas-cancel unchanged)

API ​

oas-editable ​

Attributes ​

AttributeDescriptionTypeDefault
allow-emptyAllow committing an empty value (default unchanged/non-breaking; empty restores the old value)boolean—
default-editingStart in editing on mount (consumed once)boolean—
disabledDisabledboolean—
editingControlled editing state (internal enter/exit auto-reflects; host removal takes the cancel path)boolean—
maxlengthMaximum input lengthstring—
multilineMulti-line editing (textarea; Enter for newline, Ctrl/⌘+Enter to commit, auto-grow)boolean—
placeholderEmpty value placeholderstring—
readonlyRead-only (focusable, readable, not editable, aria-readonly)boolean—
sizeSize preset small / medium (default) / largestringmedium
statusValidation status: error / warning / successstring—
submit-on-blurCommit on blur (default true; with submit-on-enter forms both/enter/blur/none)stringtrue
submit-on-enterWhether Enter submitsstringtrue
triggerTrigger: text (default, click text) / icon (pencil button, prevents misclicks) / dblclick (double-click to edit; single click doesn't trigger; Enter/Space while focused enters edit as keyboard fallback)string—
valueCurrent value (controlled)string—

Property (JS property; see each row for attribute reflection) ​

PropertyDescriptionTypeDefault
valueCurrent value: the input text while editing, otherwise the value attributestring—

Events ​

EventDescription
oas-cancelCancel/empty-value submit (reverts to old value), non-destructive by default, detail: { value: oldValue } | { value: this.getAttr('value', '') }
oas-changeNew value submitted, detail: { value }
oas-editingFires on entering/exiting editing, detail: { editing }

Slots ​

NameDescription
template[slot="display"]Custom display state ([data-display-value]/[data-display-placeholder] bindings)

Keyboard: in display mode Enter/Space/click enters edit mode; in edit mode Enter submits, Esc reverts and blurs.

ARIA: display mode has role="button" + aria-label="Edit"; the edit-mode input keeps the same label.

Released under the MIT OR Apache-2.0 License.