Editable

7 parts

Inline-editable text field that toggles between a read-only preview and an editable input. Root owns the value (via v-model), edit state, and submit / cancel behavior, providing them to its parts. Use it for click-to-edit labels, titles, and table cells where a full form input would be heavy.

Demo

Loading demo…

Anatomy

Import the parts and compose them. Each part forwards attributes to its underlying element.

vue
import {
  EditableRoot,
  EditableArea,
  EditablePreview,
  EditableInput,
  EditableEditTrigger,
  EditableSubmitTrigger,
  EditableCancelTrigger,
} from '@robonen/primitives/forms/editable';

<EditableRoot>
  <EditableArea />
  <EditablePreview />
  <EditableInput />
  <EditableEditTrigger />
  <EditableSubmitTrigger />
  <EditableCancelTrigger />
</EditableRoot>

API Reference

EditableRoot

Root

Inline-editable text field that toggles between a read-only preview and an editable input. Root owns the value (via `v-model`), edit state, and submit / cancel behavior, providing them to its parts. Use it for click-to-edit labels, titles, and table cells where a full form input would be heavy.

PropTypeDescription
defaultValue?stringUncontrolled initial value.
placeholder?string | EditablePlaceholderPlaceholder for edit / preview. A single string applies to both.
activationMode?EditableActivationModeWhen the preview should switch to edit mode.
submitMode?EditableSubmitModeHow edits are committed.
startWithEditMode?booleanMount in edit mode.
selectOnFocus?booleanSelect the input content on focus.
autoResize?booleanGrid-based auto resize mode — preview and input share a grid cell.
maxLength?numberMax input length.
disabled?booleanDisabled state.
readonly?booleanRead-only state.
dir?DirectionReading direction. When omitted, inherits from the active ConfigProvider and otherwise assumes left-to-right.
id?stringStable id, applied to the input and forwarded through context.
name?stringNative control name. When set and the Root is inside a <form>, a visually-hidden <input> submits the value with the surrounding form.
required?booleanMark the field required so native form validation fires on empty submit.
modelValue?stringTwo-way bound value (v-model).
Emits
EventPayload
update:modelValue[value: string]

EditableArea

Area

Wrapper that groups the preview and input. It mirrors edit/empty/disabled state via data attributes and, when `autoResize` is set, becomes the grid that sizes the input to match the preview text.

No props or events — renders its element and forwards attributes.

EditablePreview

Preview

Read-only display of the current value (or the preview placeholder when empty). It is focusable and, depending on `activationMode`, enters edit mode on focus or double-click.

No props or events — renders its element and forwards attributes.

EditableInput

Input

The text input shown while editing. It binds the draft value, auto-focuses (and optionally selects) when edit mode begins, and handles Enter to submit / Escape to cancel per the Root's `submitMode`.

No props or events — renders its element and forwards attributes.

EditableEditTrigger

EditTrigger

Button that enters edit mode. It is hidden while editing and disabled when the Root is disabled.

No props or events — renders its element and forwards attributes.

EditableSubmitTrigger

SubmitTrigger

Button that commits the draft value and leaves edit mode. It is only shown while editing.

No props or events — renders its element and forwards attributes.

EditableCancelTrigger

CancelTrigger

Button that discards the draft, restores the committed value, and leaves edit mode. It is only shown while editing.

No props or events — renders its element and forwards attributes.