Renaming things
Let people rename a project, document, or list title where it is displayed, without a separate settings form.
Components / Forms
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.
Owned by on the design team.
bunx --bun @getweini/cli@latest add inline-editImport 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.
<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.
Let people rename a project, document, or list title where it is displayed, without a separate settings form.
Correct a short description or note in a table or detail view, with validation that keeps the field open until it is valid.
Return a message from validate to keep editing and show the error.
<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>Use multiline for longer text and a display slot to keep line breaks.
<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>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.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
nameprop | string | undefined | Not set | Submits the committed value with a native form and registers it with Form. |
formprop | string | undefined | Not set | Associate the control with a form by its ID. |
placeholderprop | string | undefined | Not set | Hint shown when no value has been entered or selected. |
multilineprop | boolean | undefined | Not set | - Enter saves; with multiline, Ctrl or Cmd plus Enter saves and Enter adds a line. |
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
sizeprop | ControlSize | undefined | Not set | Opt into a control text-size preset. Omit to inherit surrounding typography. |
validateprop | ((value: string) => string | true) | undefined | Not set | Return `true` to accept the draft or a message to keep editing. |
messagesprop | InlineEditMessages | Required | Supply the text this component displays for its built-in actions and states. |
modelValuemodel | string | 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) | undefined | Optional | Content for the display area of InlineEdit. |
editingexposed | boolean | — | 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. |
// 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;
}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.