@gfazioli/mantine-spinner
A Mantine React component offers customizable loading animations to enhance the user experience in React applications.
Installation
After installation import package styles at the root of your application:
You can import styles within a layer @layer mantine-spinner by importing @gfazioli/mantine-spinner/styles.layer.css file.
Usage
Note: The
Spinnercomponent renders only on the client side to avoid hydration mismatches in SSR (Server-Side Rendering) environments. This is necessary because the SVG coordinates are calculated with floating-point math, which can differ between server and client. If you use SSR, the spinner will appear only after the client has mounted.
The Spinner enables the creation of a captivating spinner effect, which enhances the visual dynamics of a user interface. This effect can be used to draw attention, indicate loading processes, or provide an interactive experience that engages users effectively. By implementing this spinner effect, developers can improve the overall aesthetic appeal and functionality of their applications, ensuring a more seamless and enjoyable user experience.
Segment shapes
Use the segmentShape prop to change the shape of individual segments. Available shapes are line (default), dot (filled circles), and arc (curved path segments along the circumference).
Line
Dot
Arc
Trail variant
The trail variant creates a classic sweeping tail effect, similar to the iOS/macOS activity indicator. Each segment fades out linearly, producing a smooth trailing animation.
Neon effect
Combine variant="trail" with glow and a bright color for a neon tube effect. Set minOpacity to a value like 0.3 so segments appear always slightly lit. Control the glow intensity by passing a number to glow.
Glow
The glow prop adds a bloom/glow effect to any variant using an SVG gaussian blur filter. It can be combined with any variant, gradient, or color.
Hue rotate
The hueRotate prop continuously cycles through the color spectrum, creating a rainbow effect on the entire spinner. It can be combined with any variant, glow, and gradient for spectacular results.
Gradient
Use the gradient prop to interpolate colors across segments. The gradient transitions smoothly from from to to, overriding both color and colors.
Progress
Set the progress prop (0–100) to use the spinner as a determinate progress indicator. Animation is disabled and segments fill proportionally. Combine with children to display a label.
Spinner.Group
Spinner.Group stacks multiple spinners concentrically, aligning them on the same center point. This is useful for creating layered ring effects.
Spinner.Overlay
Spinner.Overlay wraps content and displays a semi-transparent overlay with a centered spinner on top. Control visibility with the visible prop and blur with the blur prop.
Card content
This content is covered by a loading overlay when the spinner is visible. Toggle the button below to show or hide it.
Styled
Of course, you can style the spinner as you like. For example, by adding an additional animation effect on the whole spinner.
Example: Random
Random spinner effect. Use it to create a loading effect.