Editable
7 partsInline-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
Anatomy
Import the parts and compose them. Each part forwards attributes to its underlying element.
import {
EditableRoot,
EditableArea,
EditablePreview,
EditableInput,
EditableEditTrigger,
EditableSubmitTrigger,
EditableCancelTrigger,
} from '@robonen/primitives/forms/editable';
<EditableRoot>
<EditableArea />
<EditablePreview />
<EditableInput />
<EditableEditTrigger />
<EditableSubmitTrigger />
<EditableCancelTrigger />
</EditableRoot>API Reference
EditableRoot
RootInline-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.
| Prop | Type | Description |
|---|---|---|
defaultValue? | string | Uncontrolled initial value. |
placeholder? | string | EditablePlaceholder | Placeholder for edit / preview. A single string applies to both. |
activationMode? | EditableActivationMode | When the preview should switch to edit mode. |
submitMode? | EditableSubmitMode | How edits are committed. |
startWithEditMode? | boolean | Mount in edit mode. |
selectOnFocus? | boolean | Select the input content on focus. |
autoResize? | boolean | Grid-based auto resize mode — preview and input share a grid cell. |
maxLength? | number | Max input length. |
disabled? | boolean | Disabled state. |
readonly? | boolean | Read-only state. |
dir? | Direction | Reading direction. When omitted, inherits from the active ConfigProvider
and otherwise assumes left-to-right. |
id? | string | Stable id, applied to the input and forwarded through context. |
name? | string | Native control name. When set and the Root is inside a <form>, a
visually-hidden <input> submits the value with the surrounding form. |
required? | boolean | Mark the field required so native form validation fires on empty submit. |
modelValue? | string | Two-way bound value (v-model). |
| Event | Payload |
|---|---|
update:modelValue | [value: string] |
EditableArea
AreaWrapper 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
PreviewRead-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
InputThe 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
EditTriggerButton 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
SubmitTriggerButton 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
CancelTriggerButton 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.