--- title: "Spinner" slug: spinner category: component type: documentation version: 20.0.0 tokens: 1384 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-spinner--documentation.txt --- # Spinner _A visual indicator that a process is happening in the background but the interface is not yet ready for interaction._ ## Overview A visual indicator that a process is happening in the background but the interface is not yet ready for interaction. | | | |---|---| | Name | Spinner | | Also known as | Loading, Spin, Circular Progress | | Design | https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=52-10340 | | Source | https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/spinner | ## Usage **Spinner** component is used as a fallback when complex content is loading in the background. ### Spinner vs Skeleton Both **Spinner** and [Skeleton](https://ovh.github.io/design-system/v20.0.0/components/skeleton) indicate that content is loading, but they serve different purposes: * Use a **Spinner** when the content or result is unknown and the user must wait. For example, after clicking a button or loading data from an API * Use a Skeleton when the structure of the content is known, but the actual data hasn't loaded yet. It helps set expectations and makes the wait feel shorter ### Dos & Don'ts **Do** - Use a Spinner to indicate indeterminate loading when the duration is unknown or cannot be measured - Use a Spinner when complex or background processes are happening (e.g. fetching filtered data, saving a form) - Display a Spinner if the loading is expected to take more than a couple of seconds, to reassure the user - Combine the Spinner with contextual messaging (e.g. "Loading [...]" or "Saving your changes") to clarify what's happening **Don't** - Don't use multiple Spinners on the same page, it creates confusion and visual noise. Use a single centralized Spinner or loading overlay - Don't use a Spinner for text or layout placeholders, use the Skeleton component instead, which better preserves structure - Don't use a Spinner if the loading duration is extremely short, this can feel like a flicker or visual glitch - Don't place Spinners in interactive elements like buttons without also disabling them and explaining the ongoing action ## Placement **Spinner** can be placed where needed, whether it's centered on an overlay or specific container/content in the page. **Spinner** can widen to match its container. ## Behavior The **Spinner** component has a spinning animation to show to the user that the background process is moving on. ## Variation ### Color The **Spinner** uses the accent color by default. To use another color, set the `--ods-spinner-color` CSS custom property on the **Spinner**, through its `className`, or on a container of yours, for example: * `var(--ods-semantic-color-content-neutral)`: for secondary or subtle loading indicators, commonly displayed in disabled parent components to indicate background activity without drawing too much attention * `currentColor`: to follow the text color around the **Spinner**, for example on a dark or colored background Avoid a global `[data-ods="spinner"]` selector, which would also reach the Spinners displayed by other components (Button, Input, FileUpload). A container also reaches the loading Spinners of the **Input** and **FileUpload** placed inside it; only the **Button** Spinner keeps its own color, the text color of the button. In TypeScript, setting the custom property through the `style` prop requires a cast (`style={ { '--ods-spinner-color': 'currentColor' } as CSSProperties }`), which a `className` avoids. ## Navigation The **Spinner** component is non-interactive and does not receive keyboard focus. It is purely visual and serves as a loading indicator, without affecting keyboard navigation. ## Accessibility The **Spinner** component does not automatically provide enough context for assistive technologies. To ensure accessibility, additional attributes must be applied to the container that holds the loading content. ### Indicating loading state The **Spinner** itself does not convey the loading state. This responsibility falls on the container where content is being loaded by using [aria-busy](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-busy) and [aria-live](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-live). ```tsx
``` Explanations: - `aria-busy="true"` informs assistive technologies that content is being updated. - `aria-live="polite"` ensures that the loading message is announced when necessary without interrupting. This approach ensures that users with assistive technologies understand when loading starts and ends. > Once the content is loaded, aria-busy should be set to false. ### Linking the Spinner to a loading description If the **Spinner** is associated with a specific loading action, it should be explicitly labeled using [aria-labelledby](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-labelledby) or [aria-label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Attributes/aria-label). ```tsx ``` Screen readers will announce the label, the spinner and its current state. ```tsx
Loading user profile
``` Screen readers will announce the label, the spinner and its current state.