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'
    }}
  />
);

Component Props

Property Default Details
size 'custom'

'small' | 'medium' | 'large' | 'x-large' | 'custom'

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.

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 Details
--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.

CSS Parts

Name Description
base The component’s base wrapper.

Learn more about customizing CSS parts.