UpdateButton

Patches the current record with a fixed data payload. mutationMode defaults to undoable.

Installation

pnpm dlx shadcn@latest add @chelone/update-button

Patches the current record with a fixed data payload. mutationMode defaults to undoable.

Props

PropTypeDefaultDescription
classNamestring—
confirmColor"primary" | "warning"—
confirmContentReactNode—
confirmTitleReactNode—
contentTranslateOptionsobject—
dataPartial<LooseRecord>—The fields to patch onto the record.
iconReactNode—
labelstring—
mutationModeMutationMode—`"undoable"` (default) patches the record now with an Undo notification and no dialog; the server call is deferred until the Undo window closes. `"pessimistic"` and `"optimistic"` ask for confirmation first, and `"optimistic"` closes the dialog on confirm.
onClickMouseEventHandler<HTMLButtonElement>—
onError(error: unknown) => void—Receives the error of a failed confirmed update.
onSuccess(data: LooseRecord) => void—Receives the updated record. Runs only for a confirmed update, not for an undoable one.
recordLooseRecord—
refRef<HTMLButtonElement>—
resourcestring—
titleTranslateOptionsobject—
variant"link" | "default" | "destructive" | "outline" | "secondary" | "ghost"—