Components/Spinner

Spinner

A rotating indicator for an indeterminate wait.

VerifiedSince 0.3.4

Usage

Basic

Loading demo...

Sizes

size sets the width and height in px.

Loading demo...

Visibility Toggle

visible has a built-in enter and leave transition; v-if mounts and unmounts directly.

Loading demo...

Inline Wait

For short waits inside buttons, inline status rows, or overlays.

Loading demo...

Best Practices

  • Use a spinner only for short indeterminate waits; use TxProgressBar once progress is numeric or staged, and TxLoadingState for full first-load states.
  • Put status text next to the icon; the spinner shows busy state, not a completion result.
  • Use visible for the built-in enter and leave transition; use v-if when the host owns mount timing.
  • Set fallback only where the CSS animation doesn't suit a constrained surface.
  • Tint it by setting color on TxSpinner itself; a parent's color doesn't reach past the root.

API Reference

Props

PropTypeDefaultDescription
sizenumber16Width and height in px; written to --tx-spinner-size.
strokeWidthnumber2Stroke width of the ring and the SVG; written to --tx-spinner-stroke.
fallbackbooleanfalseRenders a spinning SVG circle instead of the default ball/ring animation.
visiblebooleantrueShows or hides it with the tx-spinner-visibility transition.
labelstring'Loading'Accessible name of the status region, announced on appear; override it to localize.

Overview

  • The root is an inline-flex span with role="status", aria-busy="true", and aria-live="polite", named by label through aria-label; it announces no completion.
  • With visible=false, nothing renders once the leave transition ends.
  • fallback renders an SVG circle that reuses size and strokeWidth.
  • The root takes --tx-text-color-secondary as its color by default.

Technologies

  • Source: packages/tuffex/packages/components/src/spinner/.
查看源码
packages/tuffex/packages/components/src/spinner/index.ts