Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Forms

InlineEdit

Edit a value in place: click to edit, then save or cancel without leaving the page.

Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.

Interactive showcase

Owned by on the design team.

Install

Run in your project
bunx --bun @getweini/cli@latest add inline-edit

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Vue
<script setup lang="ts">
import { ref } from 'vue'
import InlineEdit from './components/ui/inline-edit/InlineEdit.vue'

const title = ref('Atlas launch plan')
const messages = { edit: 'Edit', saved: 'Title saved', cancelled: 'Edit cancelled' }
</script>

<template>
  <h2 class="text-3xl font-semibold tracking-tight">
    <InlineEdit
      v-model="title"
      aria-label="Project title"
      placeholder="Untitled project"
      :messages="messages"
    />
  </h2>
</template>

Click the value, press Enter, or press F2 to edit. The value inherits the font, weight, spacing, line height, and color of its surrounding heading or paragraph. Displayed text has no underline; a solid underline appears only while editing. A pointer click places the caret at that text position, including on a wrapped multiline line; keyboard and exposed edit() entry place it at the end. The text stays in place while the native field takes focus. Enter saves, Escape cancels, and leaving the field saves. Optional messages.saved and messages.cancelled provide polite announcements.

When to use it

Renaming things

Let people rename a project, document, or list title where it is displayed, without a separate settings form.

Quick text fixes

Correct a short description or note in a table or detail view, with validation that keeps the field open until it is valid.

More examples

Validated name

Return a message from validate to keep editing and show the error.

Validated name
<script setup lang="ts">
import { ref } from 'vue'
import InlineEdit from './components/ui/inline-edit/InlineEdit.vue'

const name = ref('Quarterly report')
const saved = ref('')
const messages = { edit: 'Edit name', saved: 'Name saved' }

function validate(value: string) {
  if (!value.trim()) return 'A name is required.'
  return value.length <= 24 || 'Use 24 characters or fewer.'
}
</script>

<template>
  <div class="grid max-w-sm gap-2">
    <InlineEdit
      v-model="name"
      aria-label="Document name"
      :validate="validate"
      :messages="messages"
      @save="saved = $event"
    />
    <p class="text-sm text-muted-foreground">Last saved:{{ saved || 'nothing yet' }}</p>
  </div>
</template>

Multiline notes

Use multiline for longer text and a display slot to keep line breaks.

Multiline notes
<script setup lang="ts">
import { ref } from 'vue'
import InlineEdit from './components/ui/inline-edit/InlineEdit.vue'

const notes = ref('Ship the beta on Friday.\nCollect feedback from the pilot team.')
const messages = { edit: 'Edit notes', saved: 'Notes saved' }
</script>

<template>
  <div class="grid max-w-md gap-1.5">
    <span id="release-notes" class="text-sm font-medium">Release notes</span>
    <InlineEdit
      v-model="notes"
      multiline
      name="notes"
      aria-labelledby="release-notes"
      placeholder="Add notes"
      :messages="messages"
    >
      <template #display="{ value }">
        <span class="whitespace-pre-line">{{ value }}</span>
      </template>
    </InlineEdit>
    <p class="text-sm text-muted-foreground">Press Ctrl or Cmd and Enter to save.</p>
  </div>
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

InlineEdit

Complete API for InlineEdit
NameType or signatureDefaultWhat it does
namepropstring | undefinedNot setSubmits the committed value with a native form and registers it with Form.
formpropstring | undefinedNot setAssociate the control with a form by its ID.
placeholderpropstring | undefinedNot setHint shown when no value has been entered or selected.
multilinepropboolean | undefinedNot set- Enter saves; with multiline, Ctrl or Cmd plus Enter saves and Enter adds a line.
disabledpropboolean | undefinedNot setPrevent interaction and show the disabled state.
sizepropControlSize | undefinedNot setOpt into a control text-size preset. Omit to inherit surrounding typography.
validateprop((value: string) => string | true) | undefinedNot setReturn `true` to accept the draft or a message to keep editing.
messagespropInlineEditMessagesRequiredSupply the text this component displays for its built-in actions and states.
modelValuemodelstring | undefined""Current value. Use v-model to keep it in sync with your page.
cancelevent[]—Emitted when cancel happens.
update:modelValueevent[value: string]—Requests a new model value from the parent.
saveevent[value: string]—Emitted when save happens.
displayslot((props: { value: string; }) => unknown) | undefinedOptionalContent for the display area of InlineEdit.
editingexposedboolean—Access editing from a component template ref.
editexposed() => void—Access edit from a component template ref.
saveexposed() => void—Access save from a component template ref.
cancelexposed() => void—Access cancel from a component template ref.
focusexposed() => void—Move keyboard focus to this control.
Public type definitions
Public types
// packages/frameworks/vue/components/inline-edit/types.ts
// ------- IMPORTS -------

import type { ControlSize } from '@getweini/vue/types'

// ------- TYPES -------

export interface InlineEditMessages {
  /** Spoken after the displayed value to identify its edit action. */
  edit: string
  /** @deprecated Saving is available through the keyboard and exposed save() method. */
  save?: string
  /** @deprecated Cancelling is available through Escape and the exposed cancel() method. */
  cancel?: string
  /** Optional polite announcement after a changed value is saved. */
  saved?: string
  /** Optional polite announcement after an edit is cancelled. */
  cancelled?: string
}

export interface InlineEditProps {
  /** Submits the committed value with a native form and registers it with Form. */
  name?: string
  form?: string
  placeholder?: string
  multiline?: boolean
  disabled?: boolean
  /** Opt into a control text-size preset. Omit to inherit surrounding typography. */
  size?: ControlSize
  /** Return `true` to accept the draft or a message to keep editing. */
  validate?: (value: string) => string | true
  messages: InlineEditMessages
}


// packages/frameworks/vue/dist/types/index.d.ts
export type { ButtonOptions, ButtonProps } from './button';
export type ControlSize = 'sm' | 'md' | 'lg';
export interface SelectOption<T = unknown> {
    label: string;
    value: T;
    disabled?: boolean;
}
/** Application-owned copy. Bind translated strings reactively when the locale changes. */
export interface ListboxMessages {
    /** Popup name when no aria-label or aria-labelledby is supplied. */
    listboxLabel: string;
    empty: string;
    clearSelection: string;
}
export interface ListboxProps<T> {
    options: readonly SelectOption<T>[];
    messages: ListboxMessages;
    id?: string;
    disabled?: boolean;
    required?: boolean;
    invalid?: boolean;
    name?: string;
    form?: string;
    placeholder?: string;
    size?: ControlSize;
    clearable?: boolean;
    gap?: number;
    /** Supply stable equality for object values. Values must be unique. */
    by?: (a: T, b: T) => boolean;
    /** Required for meaningful form submission of object values. */
    serialize?: (value: T) => string;
}


// packages/frameworks/vue/dist/types/button.d.ts
import type { Component } from 'vue';
/** Options shared by button implementations across frameworks. */
export interface ButtonOptions<Variant extends string = string, Size extends string = string> {
    variant?: Variant;
    size?: Size;
    disabled?: boolean;
    loading?: boolean;
    type?: 'button' | 'submit' | 'reset';
}
/** Vue-specific target options extend the reusable button contract. */
export interface ButtonProps<Variant extends string = 'default' | 'secondary' | 'outline' | 'ghost' | 'destructive', Size extends string = 'sm' | 'md' | 'lg'> extends ButtonOptions<Variant, Size> {
    as?: 'button' | 'a' | Component;
    asChild?: boolean;
}

Implementation notes

  • Omit size to inherit the surrounding typography and fit the text inline, including inside headings and paragraphs. Explicit sm, md, and lg sizes remain available as control presets. The native field keeps the same text position and adds only an edit underline. No pencil, transition, or save/cancel controls appear during editing.
  • An unchanged value leaves edit mode without a save event. A changed value emits update:modelValue and save.
  • With name, the committed value is submitted by a hidden input and registered once with Form; the wrapped field is not named.
  • Blur saves but does not pull focus back; Enter, Escape, and exposed methods return focus to the display button.

Accessibility and localization

  • messages.edit names the edit action to assistive technology. The old messages.save and messages.cancel fields remain accepted but are optional and deprecated because no action buttons are shown.
  • Keyboard focus shows the focus ring in both states; pointer entry does not add one.
  • Optional saved and cancelled messages are announced politely. Nothing is announced when they are omitted.
  • Name the control with aria-label or aria-labelledby; both reach the display button and the field.
  • Validation messages appear in a role alert paragraph linked with aria-describedby and aria-invalid.

Source contract and editing guidance