shadcn.io is not affiliated with official shadcn/ui
Spinner examples · Button
Loading Icon Button Spinner for React
A disabled icon-only button that shows just a spinner while it loads.
An icon-only button can show it's busy too. This square button is disabled and holds only a Spinner, for toolbar actions like refresh or sync where there's no room for a label.
Preview
Installation
FAQ
Why is the button a square?
size is icon-md on the Button, which is the icon-only size. The only child is a Spinner at the default size-4, so the wheel sits in the square with the button's padding around it.
Why is the icon button disabled?
So it can't be pressed again while it shows the spinner. disabled is set, and the square keeps its size at reduced opacity.
What name does the button have if there is no text?
aria-label is Loading on the Button, the name assistive tech reads. The Spinner has aria-hidden="true", so its own Loading status isn't announced twice.
Does this spinner need data-icon?
This file leaves data-icon off, because the spinner is the only child and there is no label to space it against. On a button that also has text, set data-icon to inline-start.
Related
- Loading Button SpinnerA disabled button with a spinner before
- Loading Outline Button SpinnerA disabled outline button with a spinner
- Loading Small Button SpinnerA small disabled button with a smaller
- Inline with Text SpinnerA spinner beside a Loading data
- Button with Text (Standard)The one filled action
- Loading Secondary Button SpinnerA disabled secondary button with a