Skip to content

Editable

Edit text in place, then save or cancel the change.

Demos

Size
Variant

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Editing behavior

Click the preview or Edit to begin. Submit commits the draft; Cancel restores the previous value. The preview, input, and action buttons share the selected size. Open Options and states to try activation mode, submit mode, multiline input, disabled, and read-only states.

Installation

Complete the shared installation. Copy Editable.vue and index.ts into app/components/ui/editable/. Also copy the required components: Button.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm
variantoutline, soft, bareoutline

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.
maxLengthnumber—Native 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.
ariaLabelstring—Accessible label when no Field label exists.
ariaDescribedbystringfield idsAccessible description ids.
uiEditableUi—Classes for structural parts.

Slots

SlotPropsDescription
previewvalue, isEmpty, editPreview button content.
edit—Edit button content.
submit—Submit button content.
cancel—Cancel button content.
statevalue, draft, isEditing, isEmpty, edit, submit, cancelOptional state-driven custom UI.

Events

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.

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.