Plasma Loader
An animated React loading spinner with a plasma effect: soft blobs orbit a ring and fuse together through an SVG gooey filter. Built with Motion and Tailwind CSS, sized with one prop, and accessible out of the box with a status role and screen-reader label.
- Gooey SVG filter
- Any size & color
- role="status"
- Screen-reader label
- prefers-reduced-motion
LoadingLoadingLoading
import { PlasmaLoader } from "@/components/dusk/neon/plasma-loader";
export default function PlasmaLoaderDemo() {
return (
<div className="flex items-center gap-10">
<PlasmaLoader size={32} />
<PlasmaLoader size={56} />
<PlasmaLoader size={88} />
</div>
);
}Installation
$ npx shadcn@latest add https://duskui.com/r/plasma-loader.json1. Install the dependencies.
npm install motion2. Copy the source into
components/dusk/neon/plasma-loader.tsx.plasma-loader.tsx "use client"; import * as React from "react"; import { motion, useReducedMotion } from "motion/react"; import { cn } from "@/lib/utils"; export interface PlasmaLoaderProps extends Omit<React.ComponentProps<"span">, "color" | "children"> { /** Width and height in px. */ size?: number; /** Main plasma color, any CSS color. Defaults to the theme primary. */ color?: string; /** Second color mixed into the plasma. Defaults to a hotter, whiter tint of `color`. */ secondaryColor?: string; /** Seconds for the main blob to complete one orbit. */ speed?: number; /** Text announced to screen readers. */ label?: string; } type Blob = { /** Blob diameter as a fraction of `size`. */ scale: number; /** Orbit duration multiplier. */ pace: number; /** 1 clockwise, -1 counter-clockwise. */ dir: 1 | -1; /** Starting angle in degrees. */ phase: number; tone: "main" | "second" | "core"; }; // Blobs on different paces and directions keep meeting and merging, which the // gooey filter turns into a single wobbling plasma ring. const BLOBS: Blob[] = [ { scale: 0.27, pace: 1, dir: 1, phase: 0, tone: "main" }, { scale: 0.21, pace: 1.45, dir: -1, phase: 120, tone: "second" }, { scale: 0.23, pace: 0.8, dir: 1, phase: 240, tone: "main" }, { scale: 0.15, pace: 1.2, dir: 1, phase: 60, tone: "core" }, ]; const TONES: Record<Blob["tone"], string> = { main: "radial-gradient(circle at 35% 35%, color-mix(in oklab, var(--plasma) 80%, white), var(--plasma))", second: "radial-gradient(circle at 35% 35%, var(--plasma-2), color-mix(in oklab, var(--plasma-2) 70%, var(--plasma)))", core: "radial-gradient(circle, color-mix(in oklab, var(--plasma) 60%, white), color-mix(in oklab, var(--plasma) 80%, white))", }; /** * A loading spinner made of plasma blobs orbiting a ring. An SVG * "gooey" filter fuses the blobs as they pass each other. * * Accessible as a `role="status"` region with a screen-reader label. With * reduced motion the blobs stay put and the plasma gently pulses instead. */ export function PlasmaLoader({ size = 48, color = "var(--color-primary)", secondaryColor, speed = 1.6, label = "Loading", className, style, ...props }: PlasmaLoaderProps) { const reduceMotion = useReducedMotion(); const filterId = `plasma-goo-${React.useId().replace(/[^a-zA-Z0-9_-]/g, "")}`; const orbit = size * 0.3; const duration = Math.max(0.4, speed); return ( <span role="status" aria-live="polite" data-slot="plasma-loader" className={cn("relative inline-block shrink-0 align-middle", className)} style={ { "--plasma": color, "--plasma-2": secondaryColor ?? "color-mix(in oklab, var(--plasma) 50%, white)", width: size, height: size, ...style, } as React.CSSProperties } {...props} > <span aria-hidden className="pointer-events-none absolute inset-0"> {/* Faint track so the spinner reads as a ring even between blobs. */} <span className="absolute rounded-full border" style={{ inset: size / 2 - orbit, borderColor: "color-mix(in oklab, var(--plasma) 18%, transparent)", }} /> <span className="absolute inset-0" style={{ filter: `drop-shadow(0 0 ${Math.max(2, size * 0.05)}px color-mix(in oklab, var(--plasma) 35%, transparent))`, }} > <motion.span className="absolute inset-0" style={{ filter: `url(#${filterId})` }} animate={reduceMotion ? { opacity: [1, 0.55, 1] } : { opacity: 1 }} transition={reduceMotion ? { duration: 2, ease: "easeInOut", repeat: Infinity } : { duration: 0 }} > {BLOBS.map((blob, i) => { const d = blob.scale * size; return ( <motion.span key={i} className="absolute inset-0" initial={{ rotate: blob.phase }} animate={reduceMotion ? { rotate: blob.phase } : { rotate: blob.phase + 360 * blob.dir }} transition={{ duration: duration * blob.pace, ease: "linear", repeat: Infinity }} > <span className="absolute rounded-full" style={{ width: d, height: d, left: size / 2 - d / 2, top: size / 2 - orbit - d / 2, background: TONES[blob.tone], }} /> </motion.span> ); })} </motion.span> </span> </span> <svg aria-hidden focusable="false" className="absolute size-0 overflow-hidden"> <defs> <filter id={filterId} x="-50%" y="-50%" width="200%" height="200%" colorInterpolationFilters="sRGB"> <feGaussianBlur in="SourceGraphic" stdDeviation={Math.max(1.5, size * 0.07)} result="blur" /> <feColorMatrix in="blur" type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 20 -8" result="goo" /> <feBlend in="SourceGraphic" in2="goo" /> </filter> </defs> </svg> <span className="sr-only">{label}</span> </span> ); }
Usage
import { PlasmaLoader } from "@/components/dusk/neon/plasma-loader"
export default function Loading() {
return (
<div className="grid min-h-dvh place-items-center">
<PlasmaLoader size={64} label="Loading dashboard" />
</div>
)
}Examples
Colors & speed
Mix two colors with color and secondaryColor, and change the orbit time with speed.
LoadingLoadingLoading
import { PlasmaLoader } from "@/components/dusk/neon/plasma-loader";
export default function PlasmaLoaderColorsDemo() {
return (
<div className="flex items-center gap-10">
<PlasmaLoader color="#f472b6" secondaryColor="#22d3ee" />
<PlasmaLoader color="#facc15" secondaryColor="#fb7185" speed={2.4} />
<PlasmaLoader color="#a78bfa" speed={1} />
</div>
);
}Inline status
At small sizes it sits next to text, for example while an AI response streams. Give it a specific label for screen readers.
Generating responseGenerating response…
"use client";
import * as React from "react";
import { AnimatePresence, motion } from "motion/react";
import { PlasmaLoader } from "@/components/dusk/neon/plasma-loader";
import { Button } from "@/components/ui/button";
export default function PlasmaLoaderInlineDemo() {
const [generating, setGenerating] = React.useState(true);
return (
<div className="flex w-full max-w-sm flex-col items-center gap-4">
<div className="flex h-12 w-full items-center gap-3 rounded-xl border border-white/10 bg-card px-4 text-sm">
<AnimatePresence mode="wait" initial={false}>
{generating ? (
<motion.span
key="busy"
className="flex items-center gap-3 text-white/70"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<PlasmaLoader size={22} label="Generating response" />
Generating response…
</motion.span>
) : (
<motion.span
key="done"
className="text-white/70"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
Done. Your summary is ready.
</motion.span>
)}
</AnimatePresence>
</div>
<Button variant="outline" size="sm" onClick={() => setGenerating((g) => !g)}>
{generating ? "Finish" : "Generate again"}
</Button>
</div>
);
}API Reference
Also accepts any <span> prop for the status wrapper.
| Prop | Type | Default | Description |
|---|---|---|---|
| size | number | 48 | Width and height in px. |
| color | string | var(--color-primary) | Main plasma color. |
| secondaryColor | string | — | Second color mixed into the plasma. Defaults to a whiter tint of color. |
| speed | number | 1.6 | Seconds for the main blob to complete one orbit. |
| label | string | "Loading" | Text announced to screen readers. |
Accessibility
- The wrapper has
role="status"and a visually hidden label, so assistive tech announces what is loading. - All visual layers are aria-hidden.
- The motion is a smooth orbit with no flashing.
- With prefers-reduced-motion the blobs stop orbiting and the plasma gently pulses instead, so it still reads as busy.
- Fixed width and height mean swapping it in and out never shifts layout.