Agent Orbs
Interactive orb visualization with agent states
"use client"
import { useState } from "react"
import { Button } from "@/components/ui/button"
import { AgentState, Orb } from "@/components/ui/orb"
let ORBS: [string, string][] = [
["#CADCFC", "#A0B9D1"],
["#F6E7D8", "#E0CFC2"],
["#E5E7EB", "#9CA3AF"],
]
export function OrbDemo({ small = false }: { small?: boolean }) {
const [agent, setAgent] = useState<AgentState>(null)
ORBS = small ? [ORBS[0]] : ORBS
return (
<div className="bg-card w-full rounded-lg border p-6">
<div className="mb-4">
<h3 className="text-lg font-semibold">Agent Orbs</h3>
<p className="text-muted-foreground text-sm">
Interactive orb visualization with agent states
</p>
</div>
<div className="space-y-4">
<div className="flex justify-center gap-8">
{ORBS.map((colors, index) => (
<div
key={index}
className={`relative ${index === 1 ? "block md:block" : "hidden md:block"}`}
>
<div className="bg-muted relative h-32 w-32 rounded-full p-1 shadow-[inset_0_2px_8px_rgba(0,0,0,0.1)] dark:shadow-[inset_0_2px_8px_rgba(0,0,0,0.5)]">
<div className="bg-background h-full w-full overflow-hidden rounded-full shadow-[inset_0_0_12px_rgba(0,0,0,0.05)] dark:shadow-[inset_0_0_12px_rgba(0,0,0,0.3)]">
<Orb
colors={colors}
seed={(index + 1) * 1000}
agentState={agent}
/>
</div>
</div>
</div>
))}
</div>
<div className="flex flex-wrap justify-center gap-2">
<Button
size="sm"
variant="outline"
onClick={() => setAgent(null)}
disabled={agent === null}
>
Idle
</Button>
<Button
size="sm"
variant="outline"
onClick={() => setAgent("listening")}
disabled={agent === "listening"}
>
Listening
</Button>
<Button
size="sm"
variant="outline"
disabled={agent === "talking"}
onClick={() => setAgent("talking")}
>
Talking
</Button>
</div>
</div>
</div>
)
}
Installation
pnpm dlx @elevenlabs/agents-cli@latest components add orb
Usage
import { Orb } from "@/components/ui/orb"
<Orb />
Examples
Custom Colors
<Orb colors={["#FF6B6B", "#4ECDC4"]} />
With Audio Reactivity
function AudioReactiveOrb() {
const getInputVolume = () => {
// Return normalized volume between 0 and 1
return 0.5
}
const getOutputVolume = () => {
// Return normalized volume between 0 and 1
return 0.7
}
return (
<Orb getInputVolume={getInputVolume} getOutputVolume={getOutputVolume} />
)
}
With Custom Seed
<Orb seed={12345} />
With Agent State
const [agentState, setAgentState] = useState<"thinking" | "listening" | "talking" | null>(null)
<Orb agentState={agentState} />
Manual Volume Control
const [inputVolume, setInputVolume] = useState(0.5)
const [outputVolume, setOutputVolume] = useState(0.7)
<Orb
volumeMode="manual"
manualInput={inputVolume}
manualOutput={outputVolume}
/>
API Reference
Orb
A WebGL-based 3D orb component with audio reactivity and customizable appearance.
Props
Prop | Type | Default | Description |
---|---|---|---|
colors | [string, string] | ["#CADCFC", "#A0B9D1"] | Two color values for the gradient |
colorsRef | RefObject<[string, string]> | - | Ref for dynamic color updates |
resizeDebounce | number | 100 | Canvas resize debounce in ms |
seed | number | Random | Seed for consistent animations |
agentState | AgentState | null | Agent state: null, "thinking", "listening", "talking" |
volumeMode | "auto" | "manual" | "auto" | Volume control mode |
manualInput | number | - | Manual input volume (0-1) |
manualOutput | number | - | Manual output volume (0-1) |
inputVolumeRef | RefObject<number> | - | Ref for input volume |
outputVolumeRef | RefObject<number> | - | Ref for output volume |
getInputVolume | () => number | - | Function returning input volume (0-1) |
getOutputVolume | () => number | - | Function returning output volume (0-1) |
className | string | - | Custom CSS class |
AgentState Type
type AgentState = null | "thinking" | "listening" | "talking"
Notes
- Built with Three.js and React Three Fiber for performant 3D rendering
- Uses WebGL shaders for smooth, fluid animations
- Audio reactivity can be controlled via functions (
getInputVolume
,getOutputVolume
) or refs - Agent state changes affect the orb's visual appearance and animation
- Seed prop ensures consistent animation patterns across renders
- Automatically handles canvas resizing with configurable debounce
- Colors can be updated dynamically via
colorsRef
for smooth transitions - Performance-optimized with proper cleanup and requestAnimationFrame usage
Deploy and Scale Agents with ElevenLabs
ElevenLabs delivers the infrastructure and developer experience you need to ship reliable audio & agent applications at scale.
Talk to an expert