Skip to main content
Since Shoelace 2.0 Code stable Pattern stable Figma ready

Spinner

<sl-spinner> | SlSpinner

Spinners are used to show the progress of an indeterminate operation.

Examples

Basic Spinner

By default a spinner inherits its parent element’s font size.

<sl-spinner></sl-spinner>
<div style="font-size: 32px;">
  <sl-spinner></sl-spinner>
</div>
sl-spinner
div style="font-size: 32px;"
  sl-spinner
import SlSpinner from '@teamshares/shoelace/dist/react/spinner';

const App = () => <SlSpinner />;

Size

Use the size property to display the spinner in one of 4 pre-defined sizes: small (16px), medium (32px), large (48px), and x-large (64px).

<sl-spinner size="small"></sl-spinner>
<sl-spinner size="medium"></sl-spinner>
<sl-spinner size="large"></sl-spinner>
<sl-spinner size="x-large"></sl-spinner>
<sl-spinner customSize="88px"></sl-spinner>
sl-spinner size="small"
sl-spinner size="medium"
sl-spinner size="large"
sl-spinner size="x-large"
sl-spinner customSize="88px"
import SlSpinner from '@teamshares/shoelace/dist/react/spinner';

const App = () => (
  <>
    <SlSpinner />
    <SlSpinner style={{ fontSize: '2rem' }} />
    <SlSpinner style={{ fontSize: '3rem' }} />
  </>
);

Styling the Spinner

The spinner’s track width, track color, and indicator color can be customized with the --track-width, --track-color, and --indicator-color custom properties.

<sl-spinner style="--track-width: 8px; --indicator-color: teal; --track-color: paleturquoise;" size="x-large"></sl-spinner>
sl-spinner style="--track-width: 8px; --indicator-color: teal; --track-color: paleturquoise;" size="x-large"
import SlSpinner from '@teamshares/shoelace/dist/react/spinner';

const App = () => (
  <SlSpinner
    style={{
      fontSize: '3rem',
      '--track-width': '6px'
    }}
  />
);

Importing

If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.

Script Import Bundler React

To import this component from the CDN using a script tag:

<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.1.0/cdn/components/spinner/spinner.js"></script>

To import this component from the CDN using a JavaScript import:

import 'https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.1.0/cdn/components/spinner/spinner.js';

To import this component using a bundler:

import '@shoelace-style/shoelace/dist/components/spinner/spinner.js';

To import this component as a React component:

import SlSpinner from '@shoelace-style/shoelace/dist/react/spinner';

Properties

Name Description Reflects Type Default
size The spinner’s size. If left unset, the spinner will inherit the parent element’s font size. Alternatively you can also set a custom size by passing a value to the customSize property. 'small' | 'medium' | 'large' | 'x-large' | 'custom' 'custom'
customSize Can be used to set a custom size either in pixels or rems. Whenever possible, avoid using this option and stick to the pre-defined size options. '' -
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Custom Properties

Name Description Default
--track-width The width of the track.
--track-color The color of the track.
--indicator-color The color of the spinner’s indicator.
--speed The time it takes for the spinner to complete one animation cycle.

Learn more about customizing CSS custom properties.

Parts

Name Description
base The component’s base wrapper.

Learn more about customizing CSS parts.