Skip to main content

Loader

Loaders are used to show that something is in progress. They keep users informed about the what's going on.

Demo

Usage

When to use

  • Wait times longer than a second. If the potential waiting time could be longer than a second, show a loader.

When not to use

  • Wait times are expected to be instant. Don't show a loader if the expected wait time is effectively zero, like when loading a small, cached resource. Flashing loaders can be distracting and make an interface look broken.
  • Ongoing processes. Don't show a loader for processes that are ongoing and that don't have an end. For example, don't use a loader to show that an app is running.

Variants

Quick reference

VariantUsage
circularProcesses that can't say how much they're complete.
linearProcesses that can say how complete they are, from 0 to 100%.

Circular

Demo
<CircularLoader />
  • Use a circular loader when the loading time is uncertain.

Linear

Demo
<LinearLoader amount="25" />
  • Use a linear loader when the progress can be shown as a percentage of 100%.

Format

Size

Demo
<CircularLoader extrasmall />
<CircularLoader small/>
<CircularLoader />
<CircularLoader large />
  • Circular loaders are available in four sizes.
  • Use the size that matches the size of the component being loaded.

Options

Inverted

Demo
<CircularLoader invert />
  • Inverted loaders can be used on dark backgrounds, like a blocking backdrop layer.

API Reference

CircularLoader

Usage

To use CircularLoader, you can import the component from the @dhis2/ui library

import { CircularLoader } from '@dhis2/ui'

Props

NameTypeDefaultRequiredDescription
aria-labelstring
classNamestring
dataTeststring'dhis2-uicore-circularloader'
extrasmallcustom
invertboolean
largecustom
smallcustom

LinearLoader

Usage

To use LinearLoader, you can import the component from the @dhis2/ui library

import { LinearLoader } from '@dhis2/ui'

Props

NameTypeDefaultRequiredDescription
amountnumber*The progression in percent without the '%' sign
aria-labelstring
classNamestring
dataTeststring'dhis2-uicore-linearloader'
invertbooleanUse inverted color scheme
marginstringspacers.dp12The margin around the loader, can be a full shorthand
widthstring'300px'The width of the entire indicator