Skip to content

Inline edit

A value that edits in place as text, textarea or select, with save feedback and errors.

For a value in a record's attribute list or a table cell that should be edited where it stands. In a form that is submitted as a whole, use @khaeli/input.

Text

Project

Long text

Summary

Select

Status

Custom display

Budget

Empty

Order

Slow save

Release

Rejected save

Key

Disabled

Invoice
INV-2041

Installation

npx shadcn@latest add @khaeli/inline-edit

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @keyline-icons/react ^2.2.0

Keyboard

EnterSpace
On the value, open the editor with the text selected. A list of options opens as the browser's menu.
Enter
In the editor, saves and closes it. Focus returns to the value.
Shift + Enter
In a textarea, adds a line.
Escape
Closes the editor and keeps the old value. Focus returns to the value.
Tab
Saves a changed value and moves focus on.

Accessible name

  • ariaLabel is required. It names the editor ("Project name"), and the value's button is described as "Edit Project name".
  • The button's name is the text it shows, so it reads as the value and not as a command. An empty field shows its placeholder and is named by it; with no placeholder it is named by ariaLabel.
  • After a save a polite live region says "Project name saved". A check is drawn beside the value for a moment; it is decoration.
  • When onSave throws or rejects, the editor stays open with aria-invalid, and the error's message is announced and tied to the control as its description.
  • A disabled field is text, not a button: it leaves the tab order.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/inline-edit.json