Components

Editable

Inline text editing with preview, draft, submit, cancel, and native form behavior.

Editable switches between a preview and a text input. It keeps draft and committed values separate and supports native forms.

Use Editable for in-place text editing. Use Input for a control that stays editable.

Anatomy

  • #preview: Replaces preview content. Receives the committed value, empty state, and edit action.
  • #edit: Content inside the generated edit button.
  • #submit: Content inside the generated submit button.
  • #cancel: Content inside the generated cancel button.
  • #state: Optional renderless state output with committed value, draft, edit state, and actions.

The component generates preview/input and action controls so their keyboard and form behavior stays connected. Style them with the matching ui keys.

Usage

Click the value or press Enter to edit it.

Committed value: Quarterly planning notes

Examples

Activation mode

Choose when the preview enters edit mode. focus is keyboard-friendly and is the default. dblclick avoids accidental pointer edits, while none leaves activation to the generated edit button or exposed edit() method.

<template>
  <Editable v-model="title" activation-mode="dblclick" />
</template>

Submit and cancel

submitMode controls automatic submission. Escape always cancels. In multiline mode, Ctrl+Enter or Cmd+Enter submits when Enter submission is enabled.

<template>
  <Editable v-model="summary" multiline submit-mode="both" />
</template>

Explicit submission

Set submitMode="none" when only the generated submit button or exposed method should commit the draft.

<template>
  <Editable v-model="slug" activation-mode="none" submit-mode="none" />
</template>

Field and form integration

Inside Field, Editable inherits id, name, required, disabled, and description metadata. Its hidden native control submits only the committed value.

<template>
  <Field label="Release title" name="title" required>
    <Editable v-model="title" />
  </Field>
</template>

Custom preview

The preview slot exposes an explicit action. Keep interaction on the generated preview button; only replace its content.

<template>
  <Editable v-model="title">
    <template #preview="{ value, isEmpty }">
      <strong>{{ isEmpty ? "Add a title" : value }}</strong>
    </template>
  </Editable>
</template>

Native Form Reset

A native form reset restores the initial model and clears interaction state. Calling preventDefault() on the reset event preserves the current value. Reset updates v-model without emitting value-change.

API Reference

Model

ModelTypeDefaultDescription
v-modelstring | null""Committed value. Draft input does not update it until submission.

Props

PropTypeDefaultDescription
idstringfield/generated idVisible control id.
namestringfield nameNative form field name.
placeholderstring | { preview?: string; edit?: string }"Enter text..."Shared or mode-specific placeholder.
activationMode"focus" | "click" | "dblclick" | "none""focus"Preview event that starts editing.
submitMode"blur" | "enter" | "both" | "none""blur"Events that submit the draft.
startWithEditModebooleanfalseStarts with the input visible and focused.
selectOnFocusbooleanfalseSelects input text when editing starts.
autoResizebooleanfalseUses native field-sizing: content.
multilinebooleanfalseRenders a textarea instead of an input.
rowsnumber2Initial textarea rows.
maxLengthnumberNative maximum draft length.
requiredbooleanfalseRequires a committed non-empty value.
disabledbooleanfalseDisables all controls and form submission.
readOnlybooleanfalseKeeps preview focusable but blocks editing.
invalidbooleanfalseControlled invalid state.
dir"ltr" | "rtl"inheritedText direction.
ariaLabelstringAccessible label when no Field label exists.
ariaDescribedbystringfield idsAccessible description ids.
uiEditableUiClasses for structural parts.

Emits

EventPayloadDescription
update:modelValuevalueFired after a draft is accepted.
value-change(value, details)Fired before commit. details.cancel() prevents it.
draft-change(value, details)Fired before draft input updates. Cancelable.
state-change(state, details)Fired for edit, submit, and cancel.
submit(value, details)Fired before submission completes. Cancelable.
cancel(committedValue, details)Fired before draft cancellation. Cancelable.

Slots

SlotPropsDescription
previewvalue, isEmpty, editPreview button content.
editEdit button content.
submitSubmit button content.
cancelCancel button content.
statevalue, draft, isEditing, isEmpty, edit, submit, cancelOptional state-driven custom UI.

Methods

MethodDescription
edit(event?)Enters edit mode and focuses the input.
submit(event?, reason?)Validates and commits the draft.
cancel(event?)Restores the committed value and exits edit mode.
focus()Focuses the visible edit input.

UI Options

KeyDescription
rootRoot wrapper.
hiddenInputNative form/validity input.
areaPreview/input area.
previewGenerated preview button.
inputGenerated input or textarea.
actionsAction wrapper.
editEdit button.
submitSubmit button.
cancelCancel button.

Styling Hooks

UI keyCSS classData attrs
rootakaza-editable`data-akaza-state="preview
hiddenInputakaza-editable-hidden-inputnative validity attrs
areaakaza-editable-areadata-akaza-state
previewakaza-editable-previewdata-akaza-state="preview", data-akaza-empty
inputakaza-editable-inputdata-akaza-state="editing"
actionsakaza-editable-actionsdata-akaza-state
editakaza-editable-editnative disabled attr
submitakaza-editable-submitnative disabled attr
cancelakaza-editable-cancelnative disabled attr

Plain class applies to the root wrapper. Use ui.input for the editable control.

Keyboard

KeyBehavior
EnterSubmits when submitMode includes Enter.
Ctrl+Enter / Cmd+EnterSubmits a multiline value.
EscapeCancels the draft and returns to preview mode.
TabUses native focus order; blur may submit depending on submitMode.