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).
Note: If the pre-defined sizes don’t work for your use case, you can set a custom size
using the customSize
property (as shown in the example below). Please consult the design team
before using this option, so that the team can review the pattern and determine whether the existing size
set should be updated.
<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.
Note: In general, you shouldn’t need to do this. If you are working on a design that requires custom styling, please ensure that there’s not a standard spinner in the design system that would work instead. If you really do need a non-standard spinner, please consult the design team before implementing a custom spinner, so that the team can determine whether the existing pattern should be updated.
<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'
|
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
|
— |
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.