---
title: ActivityIndicator
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { ActivityIndicator } from '@telus-uds/components-base'
import { ActivityIndicator as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'

# ActivityIndicator

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D883%253A6618" />

```jsx live
<ActivityIndicator label="Fetching products" />
```

## Introduction

`ActivityIndicator` can be used to show a visual loading state. It supports multiple modes: `inline`, `overlaid on children`, and `full screen`. It is the recommended replacement for the deprecated `Spinner` component.

## Guidance

- Avoid using an `ActivityIndicator` whenever possible. Make content available to the user as soon as possible
- User feedback should be present when a user action takes longer than 0.1 seconds
- An `ActivityIndicator` is most appropriate for providing feedback for actions that last between 2 and 10 seconds
- Use the `label` property to insert additional context for screenreader users within existing text content. For example, "this ActivityIndicator might not always be loading something."
- Actions that take longer than 10 seconds ideally provide feedback with relative progress, such as a progress bar
- Recommend not to use for full page loading
- Use the large spinner when affecting an entire content block, whose content has not finished loading, such as paginated content
- Avoid overuse: present content immediately where possible.
- The component is multiplatform and behaves consistently on Web and React Native.
- When using the overlay mode, the `ActivityIndicator` will apply a `role="presentation"` to its children elements on web platforms. This ensures that the overlaid content is properly hidden from assistive technologies while the indicator is active.

## Accessibility Considerations

- The `overlay` prop controls whether the `ActivityIndicator` is in overlay mode. When `true`, it applies `role="presentation"` to child elements on web platforms, effectively hiding them from assistive technologies.
- Ensure that the visual overlay properly blocks interactions with the underlying content to maintain consistency between visual and assistive technology experiences.
- The `label` prop is crucial for providing context to screen reader users about the current loading state.

:::warning
`ActivityIndicator` is the direct replacement for UDS `Spinner`, `Spinner` will be deprecated soon.
:::

### Accessibility

When using an `ActivityIndicator` ensure that you provide a `label` prop to explain what is happening to assistive technologies.
If you are using an ActivityIndicator 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

<AvailableOnBoth />

ActivityIndicator uses a platform-native animation on each platform and does not block on the main javascript thread on any platform.

### Overlaying children

```jsx live
<ActivityIndicator label="Fetching products" overlay>
  <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>
</ActivityIndicator>
```

### Overlaying buttons

Set `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} />
  <ActivityIndicator inline overlay variant={{ size: 'small' }}>
    <Button onPress={() => {}}>Refresh</Button>
  </ActivityIndicator>
</>
```

### Full screen `ActivityIndicator`

```jsx live
function FullScreenActivityIndicator() {
  const [visible, setVisible] = React.useState(false)

  const handleRefresh = () => {
    setVisible(true)
    setTimeout(() => setVisible(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>
      {visible && <ActivityIndicator fullScreen label="Fetching products" />}
    </>
  )
}
```

## Props

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable component="ActivityIndicator" base={BaseDocs} />

## Variants

### Style

A dot variant is primarily used as a typing indicator to signal the other party's presence and preparation for a reply.
It can also be used to communicate an ongoing activity after a user takes an action, indicating that something is happening.

```jsx live
<ActivityIndicator variant={{ style: 'dots' }} />
```

:::warning Deprecated Syntax
The following syntax is deprecated and will be removed in a future version. Please use `variant={{ style: 'dots' }}` instead.

```jsx
<ActivityIndicator variant={{ dots: true }} />
```

:::

### Size

```jsx live
<StackView space={4}>
  <ActivityIndicator label="large/default" />
  <ActivityIndicator variant={{ size: 'small' }} label="small" />
  <ActivityIndicator label="large/default with dots style" variant={{ style: 'dots' }} />
  <ActivityIndicator variant={{ size: 'small', style: 'dots' }} label="small with dots style" />
</StackView>
```

## Feedback

<Feedback component="ActivityIndicator" />
