shadcn.io is not affiliated with official shadcn/ui
Button examples · Secondary
Loading Button (Secondary) for React
A muted button, disabled, with a spinner while the action runs, when a supporting request should not be clicked twice.
Secondary styling, a spinner, and the word Loading. The button is disabled, so a second click does not start another request.
Use it for a side action like Sync or Duplicate. Keep the primary button free if people should still be able to press that. A Spinner by itself has no label. In React, Base UI does not guess when your request is done.
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="secondary" is the quieter fill. Use it when a side action such as Sync is the one in flight, and the primary button should stay available.
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 Count (Secondary)A count, kept quiet
- Button with Kbd (Secondary)A shortcut, kept quiet
- Button with Left Icon (Secondary)An icon, kept quiet
- Button with Right Icon (Secondary)An arrow, kept quiet
- Button with Text (Secondary)Quieter than the main action
- Rounded Button (Secondary)A pill, kept quiet