---
title: Spinner
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Spinner } from '@telus-uds/components-web'
import { Spinner as WebDocs } from 'docs/@telus-uds/components-web'
import AvailableOnWebOnly from '../../partials/_platform-considerations-web-only.mdx'

# Spinner

<LibraryInfo
  packageType="Web Component"
  figmaLink="https://www.figma.com/embed?embed_host=share&url=https://www.figma.com/file/4zJn2Qn6uXOqPP1GVDipy6/%F0%9F%8D%80-Allium-Components?node-id=883%3A6618"
/>

```jsx live
<Spinner label="Fetching products" show />
```

## Introduction

Spinner can be used to show a visual loading state either as a standalone element, on a specific section, or the entire screen.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

- A spinner is most appropriate for providing feedback for actions that last between 2 and 10 seconds
- Set `show` prop to `true` to display the spinner and unset it or set to `false` to hide it
- Label should be short and concise. Spinner label should accurately explain the state of the requested action along with relevant items being loaded, "Loading page content", "Logging in", "Processing payment"
- Both the small and large spinner have an overlay background to visually indicate that the content behind it is inaccessible
- Use the small spinner when applied on a button or other small interactive elements such as toggles or links
- Use the large spinner when affecting an entire web page or content block, whose content has not finished loading, such as paginated content
- Use the standalone spinner (`small` / `large`) as an interstitial placeholder for loading content
- If the Spinner should only cover its children, set the `inline` prop to `true`. If the Spinner should cover the full width of its parent regardless of the size of its children, `inline` should be set to `false`

### Accessibility

When using a `Spinner`, ensure that you provide a `label` prop to explain what is happening to assistive technologies.
If you are using a Spinner as a placeholder until content either arrives or changes, ensure that you are using an
[`aria-live` region](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) or appropriate
`role` on the parent.

### Platform considerations

<AvailableOnWebOnly />

### Overlaying children

```jsx live
<Spinner label="Fetching products" show>
  <StackView space={2}>
    <RadioCard title="Product 1">
      <Typography>A product</Typography>
    </RadioCard>
    <RadioCard title="Product 2">
      <Typography>Another product</Typography>
    </RadioCard>
    <RadioCard title="Product 3">
      <Typography>The best one yet</Typography>
    </RadioCard>
  </StackView>
</Spinner>
```

### Overlaying buttons

Set the `size` variant to `small` and `inline` prop to `true` in order to fully cover each individual button:

```jsx live
<>
  <StackView space={2}>
    <RadioCard title="Product 1">
      <Typography>A product</Typography>
    </RadioCard>
    <RadioCard title="Product 2">
      <Typography>Another product</Typography>
    </RadioCard>
    <RadioCard title="Product 3">
      <Typography>The best one yet</Typography>
    </RadioCard>
  </StackView>
  <Spacer space={2} />
  <Spinner inline variant={{ size: 'small' }} show>
    <Button onPress={() => {}}>Refresh</Button>
  </Spinner>
</>
```

### Full screen spinner

```jsx live
function fullScreenSpinner() {
  const [show, setShow] = useState(false)
  const handleRefresh = () => {
    setShow(true)
    setTimeout(() => setShow(false), 2000)
  }

  return (
    <>
      <StackView space={2}>
        <RadioCard title="Product 1">
          <Typography>A product</Typography>
        </RadioCard>
        <RadioCard title="Product 2">
          <Typography>Another product</Typography>
        </RadioCard>
        <RadioCard title="Product 3">
          <Typography>The best one yet</Typography>
        </RadioCard>
        <Button onPress={handleRefresh}>Refresh</Button>
      </StackView>
      <Spinner fullScreen label="Fetching products" show={show} />
    </>
  )
}
```

## Props

<PropsTable web={WebDocs} />

## Tokens

<TokensTable web={WebDocs} component="Spinner" />

## Variants

### Size

```jsx live
<StackView space={4}>
  <Spinner label="large/default" show={true} />
  <Spinner variant={{ size: 'small' }} label="small" show={true} />
</StackView>
```

## Feedback

<Feedback component="Spinner" />
