Skip to content

Spinner Examples

The examples below assume that you have imported the component and set up the theme.

Basic

Show that something is loading when there is no progress value. <sv-spinner> with no attributes shows the default ring shape, and screen readers announce it as a progress bar named "Loading".

Reduced Motion

The spinners on this page move slowly and the ring arc keeps one length because your system is set to reduce motion.

16px
Sets --sv-spinner-sz .
Motion
2s
Sets --sv-spinner-dur .
Ring
2px
Sets --sv-spinner-fill-thickness .
2px
Sets --sv-spinner-track-thickness .
0.12
Sets --sv-spinner-fill-min-length .
0.42
Sets --sv-spinner-fill-max-length .
Sets --sv-spinner-fill-linecap .
<div class="spinner-basic">
<sv-spinner></sv-spinner>
</div>
<style>
.spinner-basic {
display: grid;
place-items: center;
}
</style>

Label

Show text next to the spinner that says what is loading. aria-labelledby on the spinner makes that text its accessible name.

Loading results
<div class="spinner-label">
<sv-spinner aria-labelledby="spinner-label-text"></sv-spinner>
<span id="spinner-label-text">Loading results</span>
</div>
<style>
.spinner-label {
display: flex;
gap: 0.5em;
align-items: center;
justify-content: center;
}
</style>

Variants

Pick a different loading shape. variant sets one of the five built-in shapes: ring, dots, bars, lines, or pulse.

variant="ring"
variant="dots"
variant="bars"
variant="lines"
variant="pulse"
<div class="spinner-variants">
<figure>
<sv-spinner variant="ring"></sv-spinner>
<figcaption><code>variant="ring"</code></figcaption>
</figure>
<figure>
<sv-spinner variant="dots"></sv-spinner>
<figcaption><code>variant="dots"</code></figcaption>
</figure>
<figure>
<sv-spinner variant="bars"></sv-spinner>
<figcaption><code>variant="bars"</code></figcaption>
</figure>
<figure>
<sv-spinner variant="lines"></sv-spinner>
<figcaption><code>variant="lines"</code></figcaption>
</figure>
<figure>
<sv-spinner variant="pulse"></sv-spinner>
<figcaption><code>variant="pulse"</code></figcaption>
</figure>
</div>
<style>
.spinner-variants {
display: grid;
gap: 2em;
justify-items: center;
figure {
display: grid;
gap: 0.75rem;
justify-items: center;
margin: 0;
}
figcaption {
font-size: 0.8rem;
color: var(--sv-gray-3);
}
sv-spinner {
font-size: 2.5rem;
}
}
</style>

Custom Indicator

Use your own icon as the loading indicator. An SVG in the indicator slot replaces the built-in shape and turns, and aria-label names the spinner.

<div class="spinner-custom-indicator">
<sv-spinner aria-label="Syncing">
<!-- Autorenew -->
<svg fill="currentColor" height="100%" slot="indicator" viewBox="0 0 24 24" width="100%">
<path
d="M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6Zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26Z"
/>
</svg>
</sv-spinner>
</div>
<style>
.spinner-custom-indicator {
display: grid;
place-items: center;
sv-spinner {
font-size: 1.5rem;
}
}
</style>