Nazar

Morph Orb

AI chats

About

Animated AI assistant orb: 14 shapes, 6 states, 4 looks, custom colours. WebGL, zero dependencies.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Morph Orb to your project and fits it to your theme.

Code

How Morph Orb is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

import { useEffect, useState } from 'react'
import { MorphOrb, ORB_LOOKS, ORB_SHAPES, ORB_STATES, orbRamp, type OrbColors, type OrbState } from '@/components/ui/morph-orb'

// 21st reads this literal to build the controls panel: strings become text fields,
// numbers sliders, booleans toggles, a colour array a swatch set.
const settings = {
  shape: 'eclipse',
  look: 'heat',
  palette: ['#6d28ff', '#ff3d9a', '#ff8a3d', '#fff3e0'],
  speed: 1,
  glow: 0.7,
  grain: 0.25,
  size: 280,
  followCursor: true,
  autoplay: true,
}

const CAPTIONS: Record<OrbState, string> = {
  idle: 'How can I help?',
  thinking: 'Thinking it through',
  listening: "I'm listening",
  speaking: "Here's what I found",
  success: 'Done',
  error: 'Something went wrong',
}
// A conversation in miniature: [state, how long to hold it]
const SCRIPT: readonly (readonly [OrbState, number])[] = [['idle', 1600], ['listening', 2400], ['thinking', 2800], ['speaking', 3200], ['success', 1800]]
const HEX = /^#[0-9a-f]{6}$/i

export default function Demo(props: Partial<typeof settings>) {
  const s = { ...settings, ...props }
  const [state, setState] = useState<OrbState>('idle')
  const [auto, setAuto] = useState(true)
  const playing = auto && s.autoplay

  useEffect(() => {
    if (!playing) return
    let i = 0
    let id = 0
    const step = () => {
      const beat = SCRIPT[i++ % SCRIPT.length]
      if (!beat) return
      setState(beat[0])
      id = window.setTimeout(step, beat[1])
    }
    step()
    return () => clearTimeout(id)
  }, [playing])

  // Text fields accept anything, so unknown names fall back instead of breaking the orb.
  const shape = ORB_SHAPES.find((x) => x === s.shape) ?? 'eclipse'
  const look = ORB_LOOKS.find((x) => x === s.look) ?? 'heat'
  const valid = s.palette.filter((c) => HEX.test(c))
  const [a, b, c, d] = valid
  // four swatches are the ramp itself; fewer, and the ramp is built around the first one
  const colors: OrbColors = a && b && c && d ? [a, b, c, d] : orbRamp(a ?? '#ff3d9a')

  return (
    <div className="flex min-h-[480px] w-full flex-col items-center justify-center gap-4 bg-background p-6 text-foreground">
      <MorphOrb shape={shape} look={look} state={state} colors={colors} speed={s.speed} glow={s.glow} grain={s.grain} size={s.size} interactive={s.followCursor} />
      <p className="text-lg font-medium tracking-tight text-muted-foreground">{CAPTIONS[state]}</p>
      <div className="flex flex-wrap justify-center gap-1 rounded-2xl bg-muted p-1">
        {ORB_STATES.map((name) => (
          <button
            key={name}
            type="button"
            aria-pressed={name === state}
            onClick={() => {
              setAuto(false)
              setState(name)
            }}
            className={`h-8 rounded-full px-3 text-sm font-medium capitalize transition-colors ${name === state ? 'bg-background text-foreground shadow-sm' : 'text-muted-foreground hover:text-foreground'}`}
          >
            {name}
          </button>
        ))}
      </div>
    </div>
  )
}

More by Nazar

View all
  • AIMO

    AIMO

    19

More in AI chats

View all
  • AI Actions

    AI Actions

    369
  • Agent Chat

    Agent Chat

    21
  • Aquarium Prompt

    Aquarium Prompt

    189
  • AI Suggestions

    AI Suggestions

    24
  • AI Artifact

    AI Artifact

    17
  • AI Orb

    AI Orb

    228
  • Commit

    Commit

    45
  • Interactive LLM Token & Context Window Visualizer

    Interactive LLM Token & Context Window Visualizer

    13