An official website of the United States government
Official websites use .gov A .gov website belongs to an official government organization in the United States.
Secure .gov websites use HTTPS A lock or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.
Spinners signify that the application is waiting for an asynchronous operation to complete.
Changing the spinner color
To change the color of the spinner, one only has to change the color property of the spinner element. This can be done with the standard Design System utility classes. The color of the spinner also defaults to inherit, so it will take on the color of the text in its parent container.
Use inside buttons
Code snippet
<buttonclass="ds-c-button ds-u-margin-right--2"type="button"><spanclass="ds-c-spinner ds-c-spinner--small"role="status"><spanclass="ds-u-visibility--screen-reader">Loading</span></span>
Loading
<!-- --></button><buttonclass="ds-c-button ds-c-button--primary ds-u-margin-right--2"type="button"><spanclass="ds-c-spinner ds-c-spinner--small ds-c-spinner--inverse"role="status"><spanclass="ds-u-visibility--screen-reader">Loading</span></span>
Loading
<!-- --></button><buttonclass="ds-c-button ds-c-button--big ds-u-margin-right--2"type="button"><spanclass="ds-c-spinner"role="status"><spanclass="ds-u-visibility--screen-reader">Loading</span></span>
Big button
<!-- --></button><buttonclass="ds-c-button ds-c-button--success ds-c-button--big ds-u-margin-right--2"type="button"><spanclass="ds-c-spinner"role="status"><spanclass="ds-u-visibility--screen-reader">Loading</span></span>
Big green button
<!-- --></button>
"Filled" mode
To provide more contrast when being rendered over other content, the .ds-c-spinner--filled class can be added to give it an appropriately shaped background with some padding.
We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.
Loading
We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.
Loading
Code snippet
<divclass="ds-u-fill--background-inverse ds-u-color--base-inverse ds-u-padding--2"style="position: relative"><p>
We the People of the United States, in Order to form a more perfect Union,
establish Justice, insure domestic Tranquility, provide for the common
defence, promote the general Welfare, and secure the Blessings of Liberty to
ourselves and our Posterity, do ordain and establish this Constitution for
the United States of America.
</p><divclass="ds-u-display--flex ds-u-justify-content--center ds-u-align-items--center"style="position: absolute;width: 100%;height: 100%;top: 0;left: 0"><spanclass="ds-c-spinner ds-c-spinner--filled"role="status"><spanclass="ds-u-visibility--screen-reader">Loading</span></span></div></div><divclass="ds-u-padding--2"style="position: relative"><p>
We the People of the United States, in Order to form a more perfect Union,
establish Justice, insure domestic Tranquility, provide for the common
defence, promote the general Welfare, and secure the Blessings of Liberty to
ourselves and our Posterity, do ordain and establish this Constitution for
the United States of America.
</p><divclass="ds-u-display--flex ds-u-justify-content--center ds-u-align-items--center"style="position: absolute;width: 100%;height: 100%;top: 0;left: 0"><spanclass="ds-c-spinner ds-c-spinner--inverse ds-c-spinner--filled"role="status"><spanclass="ds-u-visibility--screen-reader">Loading</span></span></div></div>
Additional classes to be added to the spinner element.
Useful for adding utility classes.
inversed
boolean
Applies the inverse theme styling
filled
boolean
Adds a background behind the spinner for extra contrast
role
string
'status'
Landmark role so the spinner can receive keyboard focus
size
'small' | 'big'
Smaller or larger variant
Guidance
When to use
To indicate a loading state for quick asynchronous tasks
When to consider alternatives
When the process it is waiting for takes a long time. Spinners provide no feedback other than that we're waiting, so long processes can make users nervous that something went wrong. Consider adding descriptive text or another UX pattern entirely.
When you are loading a whole page of content. If all you show the user is a spinner, the user may spend several seconds watching the spinner to be surprised with all the content all at once. Consider using a skeleton screen so the user knows what to expect.
Usage
If the process takes a long time, use something else.
Accessibility
The Spinner element should have an aria-valuetext attribute with a value of loading to provide a human readable text alternative for screen readers.
When placed within a parent container, the parent element should include several ARIA attributes: aria-relevant, aria-live, and optionally aria-atomic.
aria-relevant may include additions, text, and removals. If a section will have items added or removed, use additions removals. If there will be additions or text changes without explicit removals, use additions text.
aria-live should be set to polite for a screen reader to speak the changes whenever the user is idle. aria-live="assertive" should only be used in situations that require a user’s immediate attention.
By default, a screen reader will only speak the contents of a changed node, and not the entire contents of the element. Set aria-atomic="true" for cases, such as an address, where a screen reader should read the contents of the entire element.
Customization
The following Sass variables can be overridden to customize Spinner components: