Orbs

Gradient orb

Three blurred blobs drifting behind a circular mask, plus a specular highlight so it reads as a sphere. No canvas, no WebGL.

  • gradient
  • css
  • ambient

Preview

Usage

<Orb size={180} colors={["#8b7bff", "#4ad9e4", "#ff7ab8"]} intensity={0.75} />
import { cn } from "@/lib/cn";

export interface OrbProps {
  size?: number;
  /** Two or three colours blended into the orb's interior. */
  colors?: [string, string, ...string[]];
  /** 0–1. Drives glow radius and saturation. */
  intensity?: number;
  /** Seconds for one full drift cycle — higher is calmer. */
  speed?: number;
  /** Glass highlight + inner shadow, so it reads as a sphere rather than a disc. */
  glass?: boolean;
  paused?: boolean;
  className?: string;
}

/**
 * A soft gradient sphere built from three blurred blobs drifting behind a
 * circular mask. Pure CSS — no canvas, no WebGL, no dependencies.
 */
export function Orb({
  size = 160,
  colors = ["#8b7bff", "#4ad9e4", "#ff7ab8"],
  intensity = 0.75,
  speed = 14,
  glass = true,
  paused = false,
  className,
}: OrbProps) {
  const blobs = colors.slice(0, 3);

  return (
    <div
      className={cn("relative isolate", className)}
      style={{ width: size, height: size }}
    >
      {/* Outer glow */}
      <div
        className="absolute inset-0 -z-10 rounded-full"
        style={{
          background: `radial-gradient(circle, ${blobs[0]} 0%, transparent 70%)`,
          filter: `blur(${size * 0.18}px)`,
          opacity: 0.25 + intensity * 0.55,
          transform: `scale(${1 + intensity * 0.35})`,
        }}
      />

      <div
        className="relative h-full w-full overflow-hidden rounded-full"
        style={{
          background: blobs[blobs.length - 1],
          boxShadow: glass
            ? `inset 0 ${size * 0.05}px ${size * 0.12}px rgba(255,255,255,.35),
               inset 0 -${size * 0.08}px ${size * 0.16}px rgba(0,0,0,.35)`
            : undefined,
        }}
      >
        {blobs.map((color, i) => (
          <span
            key={i}
            className="absolute rounded-full"
            style={{
              inset: `-${18 + i * 6}%`,
              background: `radial-gradient(circle at ${28 + i * 24}% ${34 + i * 18}%, ${color} 0%, transparent 62%)`,
              filter: `blur(${size * 0.09}px) saturate(${1 + intensity})`,
              animation: `drift ${speed + i * 3}s ease-in-out infinite`,
              animationDirection: i % 2 ? "reverse" : "normal",
              animationDelay: `${i * -2.5}s`,
              animationPlayState: paused ? "paused" : "running",
            }}
          />
        ))}

        {glass && (
          <span
            className="pointer-events-none absolute"
            style={{
              left: "16%",
              top: "10%",
              width: "44%",
              height: "30%",
              borderRadius: "50%",
              background:
                "linear-gradient(160deg, rgba(255,255,255,.75), rgba(255,255,255,0) 70%)",
              filter: `blur(${size * 0.02}px)`,
            }}
          />
        )}
      </div>
    </div>
  );
}

export default Orb;