Skip to the content
human-kit design
59 — Feedback

Spinner

Something is loading: a turning circle, alone or with what it waits for in words.

Loading history

Installation

pnpm dlx @human-kit/design add spinner
npx @human-kit/design add spinner
yarn dlx @human-kit/design add spinner
bunx @human-kit/design add spinner

The command copies the files to src/lib/components/ui/spinner. It also installs the packages that the files import.

Usage

<script lang="ts">
	import * as Spinner from '$lib/components/ui/spinner';
</script>

<Spinner.Root label="Loading the patient's history" />

Guidelines

  • Use a spinner for an area that waits on its data and has nothing to show until then.
  • Say what is loading in label when the wait is long enough to read it, or the area is large.
  • Use sm inside a line of small text, default in a panel, and lg alone in the middle of an empty area, where the label goes under the circle.
  • For an action the user started, give pending to its button instead: the spinner then sits where the user is looking.
  • For a wait whose length you know, use a progress bar.

Accessibility

  • It is a role="status", so a screen reader reads its words once when it appears, without moving the focus.
  • With no label, it still says "Loading" to a screen reader. Change it with srLabel, as "Loading the agenda".
  • The circle is hidden from assistive technology, and it stops turning when the user asks the system for reduced motion.

API reference

PropTypeDefault
size'sm' | 'default' | 'lg'

The circle and the text beside it. The large one puts the label under.

'default'
labelstring

What is loading, shown beside the circle.

—
srLabelstring

Read aloud when there is no label.

'Loading'

Plus every attribute of a <span>.