Spinner
A rotating indicator for an indeterminate wait.
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
TxProgressBaronce progress is numeric or staged, andTxLoadingStatefor full first-load states. - Put status text next to the icon; the spinner shows busy state, not a completion result.
- Use
visiblefor the built-in enter and leave transition; usev-ifwhen the host owns mount timing. - Set
fallbackonly where the CSS animation doesn't suit a constrained surface. - Tint it by setting
coloronTxSpinneritself; a parent'scolordoesn't reach past the root.
API Reference
Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | number | 16 | Width and height in px; written to --tx-spinner-size. |
strokeWidth | number | 2 | Stroke width of the ring and the SVG; written to --tx-spinner-stroke. |
fallback | boolean | false | Renders a spinning SVG circle instead of the default ball/ring animation. |
visible | boolean | true | Shows or hides it with the tx-spinner-visibility transition. |
label | string | 'Loading' | Accessible name of the status region, announced on appear; override it to localize. |
Overview
- The root is an inline-flex
spanwithrole="status",aria-busy="true", andaria-live="polite", named bylabelthrougharia-label; it announces no completion. - With
visible=false, nothing renders once the leave transition ends. fallbackrenders an SVG circle that reusessizeandstrokeWidth.- The root takes
--tx-text-color-secondaryas its color by default.
Technologies
- Source:
packages/tuffex/packages/components/src/spinner/.
查看源码
packages/tuffex/packages/components/src/spinner/index.ts