Skip to content
Dalvan UI

Loader

Show that background work is in progress with an indeterminate four-cell indicator.

Playground

Loading projects…
<span class="dv-inline-flex dv-align-items-center dv-gap-100" role="status">
  <span class="dv-loader dv-color-primary" aria-hidden="true" style="--dv-icon-size: 1.5rem; --dv-loader-duration: 1.4s">
    <span class="dv-loader__cell"></span>
    <span class="dv-loader__cell"></span>
    <span class="dv-loader__cell"></span>
    <span class="dv-loader__cell"></span>
  </span>
  Loading projects…
</span>

Usage

After setting up the CSS, place four dv-loader__cell elements inside dv-loader and give the status a useful accessible name.

<span class="dv-loader" role="status" aria-label="Loading projects">
  <span class="dv-loader__cell"></span>
  <span class="dv-loader__cell"></span>
  <span class="dv-loader__cell"></span>
  <span class="dv-loader__cell"></span>
</span>

Examples

Loader with visible status

When text already describes the operation, hide the cells and announce the status text through its container.

Loading projects…
<span class="dv-inline-flex dv-align-items-center dv-gap-100" role="status">
  <span class="dv-loader dv-color-primary" aria-hidden="true">
    <span class="dv-loader__cell"></span>
    <span class="dv-loader__cell"></span>
    <span class="dv-loader__cell"></span>
    <span class="dv-loader__cell"></span>
  </span>
  Loading projects…
</span>

Custom size and animation

Change size, color, and duration with CSS custom properties. The animation pauses when reduced motion is requested.

<span class="dv-loader dv-color-success" role="status" aria-label="Updating projects" style="--dv-icon-size: 2rem; --dv-loader-duration: 2s">
  <span class="dv-loader__cell"></span>
  <span class="dv-loader__cell"></span>
  <span class="dv-loader__cell"></span>
  <span class="dv-loader__cell"></span>
</span>

API reference

Class or attributeBehavior
dv-loaderCreates a 2 × 2 indicator sized like an icon.
dv-loader__cellUse four direct children to fill the grid and receive staggered animation.
role=statusaria-labelaria-hidden=trueName a standalone status or hide the indicator when status text already explains it.
dv-color-*Sets the palette used by the cells.

Customization

The indicator stays indeterminate at all animation speeds. Use visible status text for information about the operation.

PropertyEffect and defaults
--dv-icon-sizeOverall width and height. Falls back to 1em.
--dv-loader-colorCell color. Defaults to the current palette or text color.
--dv-loader-durationCycle time. Defaults to 1.4s.
--dv-loader-gap / --dv-loader-radiusGrid gap and cell radius. Default to 20% and 25%.
--dv-loader-idle-opacityOpacity during the faded phase. Defaults to 0.16.