Back to Sentry

IndeterminateLoader

static/app/components/core/loader/loader.mdx

26.7.22.3 KB
Original Source

import {Container, Flex, Stack} from '@sentry/scraps/layout'; import {Text} from '@sentry/scraps/text'; import {IndeterminateLoader} from '@sentry/scraps/loader';

import {Demo} from 'sentry/stories/demo';

export const documentation = import('!!type-loader!@sentry/scraps/loader');

The IndeterminateLoader renders a repeating squiggle pattern with an animated color wipe to indicate indeterminate loading progress. It fills 100% of its parent's width.

Usage

<Demo> <IndeterminateLoader /> </Demo>
jsx
<IndeterminateLoader />

Messages

Pass an array of messages to step through loading messages as the loader runs.

<Demo> <IndeterminateLoader messages={[ 'Doing the first thing', 'Doing the second thing', 'Doing the third thing', ]} /> </Demo>
jsx
<IndeterminateLoader
  messages={['Doing the first thing', 'Doing the second thing', 'Doing the third thing']}
/>

Contained Width

Constrain the loader's width by wrapping it in a sized container.

<Demo> <Stack gap="lg"> <Container style={{width: 120}}> <IndeterminateLoader /> </Container> <Container style={{width: 240}}> <IndeterminateLoader /> </Container> <IndeterminateLoader /> </Stack> </Demo>
jsx
<Container style={{width: 120}}>
  <IndeterminateLoader />
</Container>

<Container style={{width: 240}}>
  <IndeterminateLoader />
</Container>

<IndeterminateLoader />

Monochrome

Use variant="monochrome" to inherit currentColor from the parent. The track renders at 25% opacity and the accent at full opacity.

This is used internally in the Button component.

<Demo> <Stack gap="lg"> <Container style={{width: '320px', color: '#7553ff'}}> <IndeterminateLoader variant="monochrome" /> </Container> <Container style={{width: '320px', color: '#f0369a'}}> <IndeterminateLoader variant="monochrome" /> </Container> <IndeterminateLoader variant="monochrome" /> </Stack> </Demo>
jsx
<Container style={{color: '#7553ff'}}>
  <IndeterminateLoader variant="monochrome" />
</Container>

Accessibility

The component renders with role="progressbar" and a default aria-label of "Loading". Override the label to provide more specific context:

jsx
<IndeterminateLoader aria-label="Saving changes" />