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.
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.
See Storybook for React guidance of this component.
The following CSS variables can be overridden to customize Spinner components:
- To indicate a loading state for quick asynchronous tasks
- 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.
- If the process takes a long time, use something else.
- The Spinner element should have an
aria-valuetextattribute with a value of
loadingto provide a human readable text alternative for screen readers.
- When placed within a parent container, the parent element should include several ARIA attributes:
aria-live, and optionally
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
aria-liveshould be set to
politefor 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.
- Response Times
- Progress Indicators
- GOV.UK Loading patterns discussion
- Avoid the Spinner
- ARIA Live Regions
For more information about how we tested and validated our work for each checklist item, read our component maturity documentation.
ColorMeets AA color contrast standards for accessibility and color blindness.Complete
Forced Colors Mode (FCM)While using FCM the components text is legible and improves readability.Complete
WCAG 2.1 Level AA ConformanceAll Axe checks for WCAG AA compliance have passed.Complete
Screen readersVoiceOver, NVDA, and JAWS screen readers provide concise communication and interaction.Complete
Keyboard navigationComponent is fully navigable with a keyboard.Complete
StorybookComponent has stories to cover all defined props.Complete
ResponsiveComponent designed to work in all responsive breakpoints.Complete
Spanish translationsIncludes Spanish translations for default text content.Complete
CodeTokens implemented in code.Complete
DesignTokens implemented in the Sketch.Complete