Skip to content

Editable

Switch inline content between preview and validated editing states.

Usage

Basic

Use the smallest complete composition and let it own its initial value.

Use the smallest complete composition and let it own its initial value.

release-candidate
Click the value or Edit

Validated

Reject an invalid edit while preserving the last accepted value.

Reject an invalid edit while preserving the last accepted value.

release-candidate
Lowercase letters, numbers, and hyphens

Controlled

Let the parent own the current value and apply accepted changes back to the component.

Let the parent own the current value and apply accepted changes back to the component.

release-candidate
Click the value or Edit

API

Vue package: @sectile/vue/editable

Components
  • EditableRoot
  • EditableArea
  • EditablePreview
  • EditableInput
  • EditableEditTrigger
  • EditableSubmitTrigger
  • EditableCancelTrigger

Props

EditableRootProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

defaultValue

Initial value used when the component owns its state.

disabled

Whether interaction is unavailable.

label

Accessible name announced for the control.

modelValue

Current value when state is controlled by the parent.

name

Name used for native form submission.

policies

Behavior policies that customize validation, movement, or selection.

readonly

Whether the value can be inspected but not changed.

submitOnBlur

Whether leaving the editor commits the current draft.

EditablePartProps

as

Element or component rendered for this part.

asChild

Whether to merge this part into its single child instead of rendering a wrapper.

Slots

EditableRootSlotProps

disabled

Whether interaction is unavailable.

draft

Current uncommitted input text.

editing

Whether editing is active.

readonly

Whether the value can be inspected but not changed.

value

Current value exposed by this contract.

Events

EditableRoot

update:editing

Emitted when editing starts or stops.

update:modelValue

Emitted when the component requests a new controlled value.

Other types

EditableValueChangeHandler

ts
type EditableValueChangeHandler = (value: string) => void

EditableEditingChangeHandler

ts
type EditableEditingChangeHandler = (editing: boolean) => void

Parts

Shared scope: [data-scope="editable"]. Combine it with a part selector to keep styles local to this component.

PartSelectorRoleExtra attributes
root[data-part="root"]Defines the component boundary and owns its composed parts.
area[data-part="area"]Provides the two-dimensional interaction surface.
preview[data-part="preview"]Shows the committed value outside editing mode.
input[data-part="input"]Accepts the editable value or draft.
edit-trigger[data-part="edit-trigger"]Enters editing mode.
submit-trigger[data-part="submit-trigger"]Commits the current draft.
cancel-trigger[data-part="cancel-trigger"]Discards the current draft.

Keyboard interaction

KeyBehavior
EnterStart editing from the preview, or commit a single-line draft.
EscapeCancel editing and restore the accepted value.
TabMove through the preview, input, and explicit action controls.

Accessibility

Preview and input states remain distinguishable; invalid drafts are announced on the real input.

Released under the MIT License.