Components/Spinner

Spinner

A compact loading indicator for inline, overlay, and fallback loading states.

VerifiedSince 0.3.4

Usage

Spinner

Loading demo...

Best Practices

  • Use spinner for indeterminate waits only. Switch to TxProgressBar once progress is numeric or staged.
  • Keep inline spinner copy next to the icon; the spinner itself exposes busy state but no completion message.
  • Use visible when you want the built-in enter/leave transition; use v-if only when the host owns mount timing.
  • Use fallback=true only for constrained surfaces where the CSS ball animation is unsuitable.

API Reference

Props

PropTypeDefaultDescription
sizenumber16Spinner width and height in pixels; written to --tx-spinner-size.
strokeWidthnumber2Stroke width used by the ring and SVG fallback; written to --tx-spinner-stroke.
fallbackbooleanfalseRenders the SVG fallback spinner instead of the default animated ball/ring shape.
visiblebooleantrueShows or hides the spinner with the built-in tx-spinner-visibility transition.
labelstring'Loading'Accessible name for the status region, announced when the spinner appears; override it to localize.

Events

EventPayloadDescription
--No component-specific emits. Visibility is controlled by the visible prop.

Slots

SlotPropsDescription
--TxSpinner has no slots. Pair text outside the spinner for accessible status copy.

Sizes

Spinner sizes

Loading demo...

Visibility Toggle (v-if vs visible)

Toggle

Loading demo...

Dashboard Inline Waiting

Use TxSpinner for short waits inside buttons, inline status rows, or overlays. Prefer TxProgressBar when progress is known; prefer TxLoadingState for full first-load states. Spinner is best when the wait is short and no percentage is available.

Dashboard task feedback center

A screenshot-verified Spinner with Toast / Tooltip / LoadingOverlay.

Loading demo...

Overview

  • When visible=false, the spinner is not rendered after the leave transition.
  • The visible root is an inline-flex span with aria-busy="true" and aria-live="polite".
  • Default mode renders the animated ball/ring shape; fallback=true renders an SVG circle using the same size and strokeWidth props.
  • The spinner root defaults to the secondary text color (--tx-text-color-secondary); tint it by setting color on the TxSpinner element itself — a parent's color does not override the root's own declaration.

Technologies

  • Accessibility note: The visible root has aria-busy="true" and aria-live="polite", but the spinner itself has no readable label or completion announcement. Pair it with adjacent status text for anything longer than a momentary inline wait.
  • Verified coverage: spinner.test.ts checks default accessibility attributes, default vs SVG fallback branches, CSS variable mapping for size/strokeWidth, and visible=false non-rendering.
  • Component source: packages/tuffex/packages/components/src/spinner/src/TxSpinner.vue.
  • Types: packages/tuffex/packages/components/src/spinner/src/types.ts exports SpinnerProps.
  • Export alias: packages/tuffex/packages/components/src/spinner/index.ts exports Spinner, TxSpinner, SpinnerProps, and TxSpinnerInstance.
  • Coverage: packages/tuffex/packages/components/src/spinner/__tests__/spinner.test.ts verifies rendering branches and prop-driven CSS variables.
查看源码
packages/tuffex/packages/components/src/spinner/index.ts