Spinner
Installation
npx @mielui/svelte add spinneryarn dlx @mielui/svelte add spinnerbunx @mielui/svelte add spinnerUsage
Use Spinner for work with an unknown duration. A spinner on its own says nothing to a screen reader, so pass aria-label with what is loading. When visible text next to it already says so, set aria-hidden instead.
<script lang="ts">
import { Spinner } from '@mielui/svelte/components/spinner';
</script>
<Spinner aria-label="Loading invoices" />Reduced motion removes the transitions and the rotation. Rotation also pauses while the spinner is out of view or the page is hidden.
Examples
Speed and eased rotation
speed multiplies the rotation pace. eased varies the speed through each turn without stopping. The default is a steady spin.
Ready
Set ready when the work succeeds. The spinner turns into a checkmark, holds it for two seconds, then blurs and collapses on its own. Set it back to false to show the spinner again.
API reference
Spinner
Indicates loading activity.
sizenumberDiameter in pixels.
Default
16readybooleanMarks the work as finished.
Default
falsespeednumberRotation speed multiplier.
Default
1easedbooleanSpeeds up and slows down through each turn instead of spinning at a steady pace.
Default
falseclassstringClasses added to the element.
aria-labelstringAccessible name when there is no visible label.
aria-hiddenboolean | "true" | "false"Hides it from assistive technology when it is decorative.
pnpm dlx @mielui/svelte add spinner