Inline Edit

Click-to-edit text that turns into an input or auto-growing textarea in the exact same box (no layout jump) on click, Enter or F2, saves on Enter or blur and cancels on Escape, blocks saves with a validate message and shake, and runs async onSave with a pending spinner, rollback plus error on rejection, and a drawn check-mark flash on success.

Preview

Inline Edit preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/inline-edit
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

label
string

Accessible name of the field ("Name", "Bio"); also used in the edit hint.

—
value?
string
—
defaultValue?
string
—
onSave?
((next: string) => unknown)

Commit handler. Return a promise to show a pending spinner; the shown value rolls back (with a shake and the rejection message) if it rejects. Controlled callers update `value` here.

—
onCancel?
(() => void)
—
onEditingChange?
((editing: boolean) => void)
—
validate?
((next: string) => string | false | null)

Return an error message to block the save and keep the editor open.

—
multiline?
boolean

Edit in an auto-growing textarea; Enter saves, Shift+Enter adds a line.

false
placeholder?
string
Empty
maxLength?
number
—
selectOnEdit?
boolean

Select the whole text when the editor opens (default) or put the caret at the end.

true
disabled?
boolean
—
className?
string
—
classNames?
InlineEditClassNames
—

Updated