shadcn.io is not affiliated with official shadcn/ui
Button examples · Destructive
Loading Button (Destructive) for React
A destructive button, disabled, with a spinner while the delete runs, so people cannot fire the same delete twice.
The destructive button shows a spinner and Loading, and it does not accept another click. Keep the destructive color while it runs so the action still looks dangerous.
Use it after someone confirms a delete. If they have not confirmed, an Alert Dialog comes first. In React, Base UI only disables the button. It does not undo the request.
Preview
Installation
FAQ
Does this demo use isLoading?
No. It passes disabled, renders a Spinner with data-icon="inline-start", and keeps the word Loading. variant="destructive" keeps the light danger fill and danger-colored text, with the spinner and Loading in that color.
When would I use isLoading instead?
isLoading hides the label visually, centers a spinner, keeps the button's width, sets aria-busy, and disables the button. Use this demo's pattern when the word should stay visible beside the spinner.
Why is the button disabled?
So a second click can't start the request again. You set disabled yourself here. isLoading does that for you. This demo doesn't.
Can the label say something other than Loading?
Yes. The children after the spinner are ordinary text. Saving, or Deleting 3 items, is fine. The demo says Loading so the state is obvious.
Related
- Button with Text (Destructive)Delete, in the danger color
- Button with Left Icon (Destructive)An icon on a delete
- Loading Button (Standard)The main action, while it runs
- Simple Delete Confirmation Alert DialogA simple delete confirmation with a
- Button with Count (Destructive)How many the delete covers
- Button with Kbd (Destructive)A shortcut on a delete