Skip to content
Latestv1.0.63

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.

Animation Types

Description Text and Layout ​

Supports adding description text with horizontal or vertical layout.

Description Text

Color Customization ​

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

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.

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.

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.

Container Mode

Custom Slots ​

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

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.

Nuxt Usage Example

SSR Rendering

Spin is SSR-safe because it renders regular markup from props and slots. The loading animation itself starts naturally on the client after hydration.

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>undefined
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

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 ​

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 modeundefined

Type Exports ​

NameDescription
YhSpinPropsComponent props type
YhSpinEmitsComponent emits type
YhSpinSlotsComponent slots type
YhSpinExposeComponent expose type
YhLoadingSpinnerTypeBuilt-in loading animation union type
YhSpinInstanceComponent instance type

Released under the MIT License.