shadcn.io is not affiliated with official shadcn/ui
Button examples · Standard
Loading Button (Standard) for React
A filled button, disabled, with a spinner and the word Loading, while the main action is still running its request.
The default button turns the click off and shows a spinner in front of Loading. A spinner on a button that still clicks will fire the request twice.
Use it for Save or Submit from the moment you send until you get an answer. If the wait is the whole page, a Spinner outside the button is clearer. In React, the button stays disabled only as long as you keep it disabled.
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. This one leaves variant off, so the primary fill stays while it runs.
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 (Standard)The one filled action
- Button with Left Icon (Standard)An icon on the main action
- Loading Button (Outline)An outline, while it runs
- Loading Button (Link)A quiet action, while it runs
- Button with Count (Standard)A count on the main action
- Button with Kbd (Standard)A shortcut on the main action