Documentation

A rotating circular spinner with a gradient foreground that transitions from --loader-foreground to --loader-foreground-end. The center is cut out using an ::after pseudo-element with --loader-background color, creating a ring/donut shape. Spins continuously with a 1.4s linear animation. A standalone shape, not designed to sit inline in running text — for a spinner that flows naturally inside text or a button label, use LoadingDots instead.

Usage

<script>
  import { Loader } from '@juspay/svelte-ui-components';
</script>

<Loader />

Props

Prop Type Required Default Description
variant 'default' | 'border' | 'orbit' No default Opt-in ring/orbit paint; the existing gradient stays the default.
ariaLabel string No unset Optional standalone status name; omit when a parent status owns the loading message.
classes string No - CSS class string applied to the component's top-level element. Useful for theming — define classes with CSS variable overrides and pass them to create variant styles.
testId string No - data-pw/testID on the root element.

CSS Variables

Override these custom properties to theme the component.

Variable Default CSS Property Description
--loader-font-size 10px font-size Font size (used internally for text-indent trick).
--loader-text-indent -9999em text-indent Text indent to hide text content.
--loader-width 20px width Width of the spinner.
--loader-height 20px height Height of the spinner.
--loader-border-radius 50% border-radius Corner rounding of the spinner (50% for circle).
--loader-foreground - background Gradient start color of the spinner ring.
--loader-foreground-end - background Gradient end color of the spinner ring.
--loader-before-width 10px width Width of the ::before pseudo-element (top gradient).
--loader-before-height 10px height Height of the ::before pseudo-element.
--loader-before-border-radius 100% 0 0 0 border-radius Corner rounding of the ::before element.
--loader-before-position absolute position CSS position of the ::before element.
--loader-before-top 0 top Top position of the ::before element.
--loader-before-left 0 left Left position of the ::before element.
--loader-background - background Color of the center cutout (creates the ring hole).
--loader-after-width 15px width Width of the center cutout circle.
--loader-after-height 15px height Height of the center cutout circle.
--loader-after-border-radius 50% border-radius Corner rounding of the cutout (50% for circle).
--loader-after-position absolute position CSS position of the cutout.
--loader-after-top 50% top Top position of the cutout.
--loader-after-left 50% left Left position of the cutout.
--loader-spin-duration 1.4s animation Duration of the spin animation. Falls back through --motion-duration. Named -spin- rather than -animation- to avoid colliding with GridItem's unrelated --loader-animation-duration.
--loader-spin-easing linear animation Easing curve of the spin animation. Falls back through --motion-easing.

Web Component

Tag: <sui-loader>

<sui-loader></sui-loader>

Border and orbit variants

variant="border" renders a three-quarter border ring. variant="orbit" renders two rotating dots. Both keep a visible static shape for reduced motion. Existing calls without variant retain the original gradient loader and token defaults.

<Loader variant="border" ariaLabel="Loading orders" />
<Loader variant="orbit" ariaLabel="Loading content" />
Token Default Purpose
--loader-border-width 2px Border-ring thickness
--loader-active-color #6c5ff9 Active border color
--loader-track-color #e0e0e0 Remaining border color
--loader-orbit-dot-size 24px Orbit dot dimensions
--loader-orbit-dot-radius 50% Orbit dot rounding
--loader-orbit-primary #6c5ff9 Primary orbit dot
--loader-orbit-secondary #f3f4f6 Secondary orbit dot

The existing width/height, radius and spin-duration/easing tokens also apply. Border defaults to 20px; orbit defaults to 48px and both new variants default to one second. <sui-loader> accepts variant and aria-label; the JS label adapter is loaderAriaLabel, preserving the native host ariaLabel accessor.