Skip to content

Spin

Loading feedback for pages, cards, or local areas. YH-UI's Spin adopts a minimalist design, supporting standard SVG animations and providing a dynamic dot (Dot) mode.

Basic Usage

Provides standard SVG animation with multiple size options, and also supports passing explicit pixel values.

Size Options

Dot Mode

Inspired by excellent component libraries' 4-dot rotation mode, with more dynamic and rhythmic visuals.

Dot Mode

Premium Animations

In addition to the basic circle animation, YhSpin also provides various premium SVG animations to meet different visual aesthetic needs.

Circle (default)
Chaser
Gear
Dual Ring
Rect
Animation Types

Description Text and Layout

Supports adding description text with horizontal or vertical layout.

Loading...
Optimizing resources...
Description Text

Color Customization

Supports custom colors, and can even pass CSS gradient values for more advanced visual effects.

Urgent Processing
Syncing
Aurora Gradient
Warm Dot
Color Customization

Glass Mask Mode

The glass prop enables Gaussian blur mask effect for fullscreen or local areas, commonly used for state locking after important page operations.

Business Secret Protection Area

This is a local container with Glass mode applied. During sensitive operations (such as key generation, financial exports), enabling Gaussian blur mask can effectively prevent background content leakage and lock operations in the current area.

Glass Mask

Delayed Display (Anti-flicker)

For some extremely fast requests (e.g., < 100ms), immediately showing loading animation may cause visual "flickering" discomfort. Use the delay prop to set delayed display time.

No delay:
500ms delay:
Delayed Display

Container Mode (Advanced Usage)

Spin can be used as a container component to wrap other content. When show is true, the container automatically enters loading state and applies Gaussian blur.

Data Dashboard

This is content wrapped by Spin. Toggle the button below to control the loading state visibility.

When loading is enabled, the content area will automatically apply Gaussian blur filter and show loading animation.

Loading data...
Container Mode

Custom Slots

The tip slot allows complete customization of the description text area content.

[SYSTEM] Scanning disk... 80%
Slot Customization

Use in Nuxt

Spin is fully compatible with Nuxt 3/4 environments. In Nuxt projects, components are automatically imported, and you can easily implement fullscreen or local loading effects with async APIs like useFetch.

Request in progress...
Nuxt Usage Example

SSR Rendering

Spin component does not render Spinner animation during SSR until client-side hydration is complete, ensuring it does not affect first-screen parsing performance.

API

Props

PropDescriptionTypeDefault
showWhether to show loading statebooleantrue
tipDescription textstring-
sizeSize, supports keywords or custom px value'small' | 'default' | 'large' | number'default'
verticalWhether to arrange icon and text verticallybooleanfalse
delayDelay display time (ms), anti-flickernumber0
glassWhether to enable fullscreen glass mask modebooleanfalse
dotWhether to use dot animationbooleanfalse
typeLoading animation style type. Options: circle, chaser, gear, dual-ring, rectLoadingSpinnerType'circle'
colorCustom color (supports hex, RGB, CSS gradient string or gradient config object)string | string[] | Record<string, string>-

Events

Event NameDescriptionParameters
showTriggered when loading state shows-
hideTriggered when loading state hides-

Slots

Slot NameDescription
defaultWrapped content. If this slot exists, Spin runs in container mode
tipCustom description text area

Expose

NameDescriptionType
visibleWhether the animation is currently visibleComputedRef<boolean>

Theme Variables (CSS Variables)

The component supports customization via the following variables:

VariableDescriptionDefault
--yh-spin-colorBase color of loading iconvar(--yh-color-primary)
--yh-spin-blur-radiusBlur radius in container mode8px
--yh-spin-mask-bgMask background in container modergba(255, 255, 255, 0.4)
--yh-spin-mask-bg-darkMask background in dark modergba(0, 0, 0, 0.3)
--yh-spin-gradientCSS background value in gradient mode-

Released under the MIT License.