Spinner
A loading indicator with Apple-style ticks or a breathing ring that can wait before showing and stay long enough not to flicker.
- Feedback components
- 1 parts
- 5 examples
- vs shadcn/ui
class-variance-authority
See it in a real product: Artifact, Chat Sidebar, Code Block, and 20 more
View blockpnpm dlx shadcn@latest add https://hextaui.com/r/spinner.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add class-variance-authority cnCopy and paste the following code into your project.
components/ui/spinner.tsx Update the import paths to match your project setup.
The default is the eight-spoke indicator from Apple platforms. variant="ring" spins while its arc grows and shrinks, so it reads as working rather than stuck. Both are drawn in the current text color.
Pass loading and the spinner waits delay (150ms) before showing, so fast loads never flash it, then stays at least minDuration (400ms) once it's visible.
sm, default, lg and xl for both variants.
Next to text, mark the spinner aria-hidden so the words do the talking. On its own, it announces its label.
Button and Command use this spinner for their loading states, sized to the button's icons.
- On its own, the spinner is a
statusnamed bylabel(“Loading”). - With
aria-hidden, it drops its role, for use beside visible text or inside a busy button. - With reduced motion, it gently pulses instead of spinning, so it still shows that something is happening.
| Prop | Type | Default |
|---|---|---|
variant | "ticks" | "ring" | "ticks" |
sizenull leaves sizing to the parent. | "sm" | "default" | "lg" | "xl" | null | "default" |
label | string | "Loading" |
loadingTurns on delayed showing. Leave it out to always show. | boolean | – |
delay | number | 150 |
minDuration | number | 400 |
animatedPause the animation without hiding it. | boolean | true |
| Attribute | Description |
|---|---|
data-slot="spinner" | The SVG, with data-variant. |
The same timing as a hook, for skeletons, overlays or anything else that shouldn't flash. See the useDelayedLoading guide.
- useDelayedLoadingShows a loading state only when work is actually slow, then keeps it up long enough that it never flickers.
- AlertInline messages for status and feedback, with a neutral surface, a colored icon and a dismiss that collapses smoothly.
- EmptyA placeholder for screens with nothing to show yet, with an icon, a message and the next action.
- ProgressA bar or ring that shows how far a task has come, eases between updates and slides while the total is unknown.
- SkeletonPlaceholders that wait 150ms before showing, take the exact size of the content they wrap, and fade it in without moving anything.
- ToastBrief messages that stack neatly, expand on hover, swipe away, and turn a loading state into success or error in place.
Used in Pro blocks
Blocks that build on Spinner.
Every block comes with HextaUI Pro, and Prompt Input is free.