Skip to content
Thrum

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-edit

This 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

PropTypeDefaultDescription
aria-labelstringRequiredWhat the text is, such as "Project name". It names the field, and the button reads it before the value.
valuestring–The saved text, when the parent holds it. Update it from onSave.
defaultValuestringDefault ""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.
placeholderstringDefault "Empty"Shown in the muted colour while the text is empty, in both states.
multilinebooleanDefault falseA 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.
showButtonsbooleanDefault falseShow save and cancel buttons after the field.
requiredbooleanDefault falseAn empty edit is refused with Enter a value, and the field stays open.
maxLengthnumber–The longest text the field takes, in characters.
size"sm" | "md" | "lg"Default "md"28, 32 or 40 pixels tall, in both states.
disabledbooleanDefault falseShown as text that cannot be opened.
soundbooleanDefault truePlay subtle save, error and cancel sounds, if the visitor has sound on.
classNamestring–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.
KeysAction
Enter / Space / F2On the text: open the field with the text selected.
EnterSave and close. In a multiline field Enter breaks the line.
Ctrl Enter / Cmd EnterMultiline: save and close.
EscDrop the edit and close. A dialog around it stays open.
TabLeave the field, which saves or cancels as blurAction says. With buttons, move to Save and Cancel first.

Source

SourcePro

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. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor