Spinners
Use Spinner to indicate a component or page loading state. It is styled with CSS and requires no JavaScript.
Spinner accepts animation="border" or "grow", size="sm", and native element attributes.
SpinnerIcon applies the rotation animation to an Icon from the icon font.
Spinner visibility can be controlled by rendering it conditionally. Customize its color with className, alignment with layout utilities, and size with its size prop.
For accessibility, provide an accessible name such as aria-label="Loading" when Spinner uses role="status".
The animation effect depends on the
prefers-reduced-motionmedia query. See the reduced motion section of our accessibility documentation.
Border spinner
Use the border spinners for a lightweight loading indicator.
<div className="d-flex align-items-center gap-3">
<Spinner
aria-label="Loading"
role="status"
/>
<Badge theme="primary">
<Spinner aria-hidden="true" />
<span role="status">
Loading
</span>
</Badge>
<Button
disabled
theme="primary"
variant="subtle"
>
<Spinner aria-hidden="true" />
<span role="status">
Loading…
</span>
</Button>
</div>Growing spinner
If you don’t fancy a border spinner, switch to the grow spinner. While it doesn’t technically spin, it does repeatedly grow!
<div className="d-flex align-items-center gap-3">
<Spinner
animation="grow"
aria-label="Loading"
role="status"
/>
</div>Variants
Spinners use currentColor, so pass a text-color utility through className to customize their
appearance.
<div className="d-flex align-items-center gap-3">
<Spinner
aria-label="Loading"
className="fg-primary"
role="status"
/>
<Spinner
animation="grow"
aria-label="Loading"
className="fg-accent"
role="status"
/>
</div>Size
Spinner is 1em square by default. Set size="sm" for a smaller indicator that fits inside other components.
<div className="d-flex align-items-center gap-3">
<Spinner
aria-label="Loading"
role="status"
size="sm"
/>
<Spinner
animation="grow"
aria-label="Loading"
role="status"
size="sm"
/>
</div>Or, use custom CSS or inline styles to change the dimensions as needed.
<div className="d-flex align-items-center gap-3">
<Spinner
aria-label="Loading"
role="status"
style={{
height: '3rem',
width: '3rem'
}}
/>
<Spinner
animation="grow"
aria-label="Loading"
role="status"
style={{
height: '3rem',
width: '3rem'
}}
/>
</div>Custom spinners
Use SpinnerIcon to apply the rotation animation to an Icon.
<div className="d-flex flex-wrap gap-2 align-items-center">
<SpinnerIcon
aria-hidden
name="arrow-repeat"
/>
</div>CSS
Variables
Customize the component with the following local CSS variables. Override them through the wrapper’s style prop or your own CSS module.
Border spinner tokens:
| CSS variable | Default |
|---|---|
--bs-spinner-width | 1em |
--bs-spinner-height | 1em |
--bs-spinner-border-width | 0.125em |
--bs-spinner-animation-speed | 1s |
--bs-spinner-animation-timing-function | linear |
--bs-spinner-animation-name | spinner-border |
Growing spinner tokens:
| CSS variable | Default |
|---|---|
--bs-spinner-width | 1em |
--bs-spinner-height | 1em |
--bs-spinner-animation-speed | 1s |
--bs-spinner-animation-timing-function | linear |
--bs-spinner-animation-name | spinner-border |
Keyframes
Used for creating the CSS animations for our spinners. The border spinner rotates through 360deg; the grow spinner scales from 0 to its full size while fading in. Use SpinnerIcon to apply the rotation animation to an icon from the icon font.