Orbs

Pulse orb

A listening indicator driven by a 0–1 level. Rings trail the core by 55ms each, which is what makes it feel responsive rather than mechanical.

  • voice
  • listening
  • reactive
  • agent

Preview

level 0.00

Usage

const level = useAudioLevel(stream);

<PulseOrb level={level} size={140} rings={3} />
"use client";

import { cn } from "@/lib/cn";

export interface PulseOrbProps {
  /** 0–1 activity level. Drive it from an analyser node, a stream, or a timer. */
  level?: number;
  size?: number;
  color?: string;
  /** Concentric rings that expand with the level. */
  rings?: number;
  /** Dim, still state for when nothing is happening. */
  idle?: boolean;
  className?: string;
}

/**
 * Listening / thinking indicator. The core scales with `level` while the rings
 * trail behind it, which reads as responsiveness even at low frame rates.
 */
export function PulseOrb({
  level = 0,
  size = 120,
  color = "var(--color-accent)",
  rings = 3,
  idle = false,
  className,
}: PulseOrbProps) {
  const l = idle ? 0 : Math.min(1, Math.max(0, level));
  const core = size * (0.42 + l * 0.22);

  return (
    <div
      className={cn("relative grid place-items-center", className)}
      style={{ width: size, height: size }}
    >
      {Array.from({ length: rings }, (_, i) => {
        const step = (i + 1) / rings;
        return (
          <span
            key={i}
            className="absolute rounded-full"
            style={{
              width: core + size * 0.28 * step * (0.5 + l),
              height: core + size * 0.28 * step * (0.5 + l),
              border: `1.5px solid ${color}`,
              opacity: (0.34 - i * 0.08) * (0.35 + l),
              transition: `width 320ms var(--ease-out-quint), height 320ms var(--ease-out-quint), opacity 320ms linear`,
              transitionDelay: `${i * 55}ms`,
            }}
          />
        );
      })}

      <span
        className={cn("rounded-full", idle && "animate-breathe")}
        style={{
          width: core,
          height: core,
          background: `radial-gradient(circle at 34% 30%, color-mix(in oklab, ${color} 45%, white), ${color})`,
          boxShadow: `0 0 ${size * 0.22 * (0.3 + l)}px ${color}`,
          transition: "width 220ms var(--ease-spring), height 220ms var(--ease-spring), box-shadow 220ms linear",
        }}
      />
    </div>
  );
}

export default PulseOrb;