Inline edit
Text that turns into a field when it is pressed: a title, a name, a short note, edited where it is read. Use it where values are mostly read and sometimes changed. For a form that is filled in from the start, use plain inputs.
Install
npx shadcn@latest add @thrum-pro/inline-editThis is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.
Automatically installs icons check, circle-alert, pencil and x from the icon set.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | Required | What the text is, such as "Project name". It names the field, and the button reads it before the value. |
value | string | – | The saved text, when the parent holds it. Update it from onSave. |
defaultValue | string | Default "" | The text at first, when the component holds it itself. |
onSave | (value: string) => void | Promise<void> | – | Called with the new text when an edit is saved. A returned promise shows Saving… and locks the field; a rejection keeps it open and prints the error's message. |
onCancel | () => void | – | Called when an edit is dropped by Escape, the cancel button or a blur that cancels. |
onEditingChange | (editing: boolean) => void | – | Called when the field opens or closes. |
placeholder | string | Default "Empty" | Shown in the muted colour while the text is empty, in both states. |
multiline | boolean | Default false | A text area that grows with its lines up to 192 pixels. Enter breaks a line; Ctrl or Cmd with Enter saves. |
blurAction | "save" | "cancel" | Default "save" | What leaving the field does. Moving to the save or cancel button does not count as leaving. |
showButtons | boolean | Default false | Show save and cancel buttons after the field. |
required | boolean | Default false | An empty edit is refused with Enter a value, and the field stays open. |
maxLength | number | – | The longest text the field takes, in characters. |
size | "sm" | "md" | "lg" | Default "md" | 28, 32 or 40 pixels tall, in both states. |
disabled | boolean | Default false | Shown as text that cannot be opened. |
sound | boolean | Default true | Play subtle save, error and cancel sounds, if the visitor has sound on. |
className | string | – | Classes for the root element. Set the width here; the text fills it. |
Motion and sound
Motion
- At rest the read state shows a subtle dashed frame and pencil cue; hover and focus bring the frame solid and the pencil to full opacity over 150 ms.
- Opening and closing swap the button and the field in one frame. Both have the same border, padding and height, so nothing moves.
- Reduced motion: the hover frame and pencil change at once.
Sound
- A two-note rise when an edit saves, a soft error tone when validation or save fails, and a light tick when an edit is cancelled.
Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works
Accessibility
- The read state is a button named by the label, the value and the word edit, as in Project name: Northwind launch plan, edit.
- The field takes the same label as its name. Focus moves into it on opening and back to the button on closing.
- While a save is pending the field is read-only and aria-busy, and Saving… is announced as a status.
- An error marks the field invalid, is linked to it as its description, and keeps the focus in the field.
- A long single-line value is cut with an ellipsis in the read state and keeps its full text in a tooltip and in the button's name.
| Keys | Action |
|---|---|
| Enter / Space / F2 | On the text: open the field with the text selected. |
| Enter | Save and close. In a multiline field Enter breaks the line. |
| Ctrl Enter / Cmd Enter | Multiline: save and close. |
| Esc | Drop the edit and close. A dialog around it stays open. |
| Tab | Leave the field, which saves or cancels as blurAction says. With buttons, move to Save and Cancel first. |
Source
The source comes with Pro
TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies
Files and dependencies
- Adds
components/ui/inline-edit.tsx- Packages
- None
- Brings along
- ButtonSound engine
- Icons
checkcircle-alertpencilx
Changelog
- 1.0.0 · 2026-12-03First release.