Spinner

updated

A loading indicator driven by clip-path, inheriting its colour from currentColor.

Source
Demo

Installation

Usage

It carries no colour of its own and no size beyond the surrounding text's — it inherits currentColor and is 1em square until a class or a button sizes it, which is what lets it drop straight into a button.

In a button

API Reference

The only prop is class, merged over the base classes. Size and colour come from there, or from the surrounding text.

Data attributes

data-slotAttributesDescription
spinnerdata-icon="inline-start"The svg. Marks itself as a leading icon so a Button tightens its start padding.

Accessibility

The spinner is aria-hidden. On its own it announces nothing useful, so the state belongs on the control that is busy — a live region you own, or aria-busy you add yourself. Under prefers-reduced-motion: reduce it freezes at its widest frame rather than disappearing, so it still reads as loading.

Changelog

  1. registry 0.22.0

    9a6eefe — A bare <Spinner /> is 1em square, the size of the surrounding text, instead of as wide as its container; a size class or a Button still sizes it. Its styles sit in @layer components, so a class such as animate-none now replaces its animation.

  2. registry 0.8.0

    b68c6ee — InnerLoading: InnerLoading, InnerLoadingContent and InnerLoadingOverlay, a loading overlay for one region. The content turns inert while loading, so nothing behind the scrim can be clicked, focused or read; the overlay mounts only while loading with a Spinner by default, and focus returns to the control that had it when loading ends.

    686b10b — ImageLoading and ImageError leave the render tree (display: none) while their state is not showing, so the default Spinner stops animating behind loaded images. The fade still plays through transition-behavior: allow-discrete and @starting-style, and a display class passed to a layer still wins while it is shown.