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 attribute | Behavior |
|---|---|
dv-loader | Creates a 2 × 2 indicator sized like an icon. |
dv-loader__cell | Use four direct children to fill the grid and receive staggered animation. |
role=statusaria-labelaria-hidden=true | Name 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.
| Property | Effect and defaults |
|---|---|
--dv-icon-size | Overall width and height. Falls back to 1em. |
--dv-loader-color | Cell color. Defaults to the current palette or text color. |
--dv-loader-duration | Cycle time. Defaults to 1.4s. |
--dv-loader-gap / --dv-loader-radius | Grid gap and cell radius. Default to 20% and 25%. |
--dv-loader-idle-opacity | Opacity during the faded phase. Defaults to 0.16. |