Spinner

lightning:spinner

Displays an animated spinner.

For Aura components only. For LWC development, use lightning-spinner.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline

A lightning:spinner displays an animated spinner image to indicate that a feature is loading. This component can be used when retrieving data or anytime an operation doesn’t immediately complete.

The variant attribute changes the appearance of the spinner. If you set variant="brand", the spinner matches the Lightning Design System brand color. Setting variant="inverse" displays a white spinner. The default spinner color is dark blue.

This component implements styling from spinners in the Lightning Design System.

Here is an example.

1<aura:component>
2  <lightning:spinner variant="brand" size="large" />
3</aura:component>

lightning:spinner is intended to be used conditionally. You can use aura:if or the Lightning Design System utility classes to show or hide the spinner.

1<aura:component>
2  <lightning:button label="Toggle" variant="brand" onclick="{!c.toggle}" />
3  <div class="exampleHolder">
4    <lightning:spinner aura:id="mySpinner" />
5  </div>
6</aura:component>

This client-side controller toggles the slds-hide class on the spinner.

1({
2  toggle: function (cmp, event) {
3    var spinner = cmp.find("mySpinner");
4    $A.util.toggleClass(spinner, "slds-hide");
5  },
6});

Attributes 

NameDescriptionTypeDefaultRequired
alternativeTextThe alternative text used to describe the reason for the wait and need for a spinner.String
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]
classA CSS class for the outer element, in addition to the component's base classes.String
sizeThe size of the spinner. Accepted sizes are small, medium, and large. This value defaults to medium.Stringmedium
titleDisplays tooltip text when the mouse moves over the element.String
variantThe variant changes the appearance of the spinner. Accepted variants are base, brand, and inverse. This value defaults to base.String