Components73 / 118
AI Chat Panel
An assistant card lit from inside by a living aurora. It greets you word by word; every keystroke pulses the light; sending flies your question into a bubble while the input drops away, and the answer streams in word by word, glowing violet before it settles. The aurora leans toward your cursor and breathes with the answer.
AIAIChatChatStreamingStreamingAuroraAuroraSquash & stretchSquash & stretchGSAPGSAP
Move over the cardType and press Enter
Tweak
LIVELIVEText
Demo
Play a question on load
Usage
Follows your tweaks.
usage.tsx
import { AiChatPanel } from "@/components/inreact/ai-chat-panel";
export function Assistant() {
return (
<AiChatPanel
respond={async (question) => {
const res = await fetch("/api/ask", { method: "POST", body: JSON.stringify({ question }) });
return res.text();
}}
/>
);
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/ai-chat-panel.jsonOr copy the source
Install the dependencies, then save this as components/inreact/ai-chat-panel.tsx.
terminal
npm install gsapcomponents/inreact/ai-chat-panel.tsx
"use client";
import { gsap } from "gsap";
import { useCallback, useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
/**
* AI Chat Panel: an assistant card lit from inside by a living aurora.
*
* A dark glass card with a magenta and violet aurora glowing inside it. It
* greets you word by word; type and every keystroke sends a pulse through the
* aurora, and the mic turns into a send arrow. Send and your question flies up
* into a message bubble (stretching as it travels, squashing as it lands) while
* the input drops to the bottom; the answer streams in word by word, each word
* glowing violet before it settles white, and the aurora breathes with it. Then
* copy / rate / share / retry hop in. The aurora also leans toward your cursor.
* Click the title to start a new chat.
*
* <AiChatPanel respond={async (q) => (await fetch("/api/ask", { ... })).text()} />
*/
export interface AiChatPanelProps {
title?: string;
greeting?: string;
placeholder?: string;
/** Produce the answer (string or promise). It is streamed in word by word. */
respond?: (question: string) => string | Promise<string>;
/** Card size, px. */
width?: number;
height?: number;
/** Type and send this question by itself (and loop, for showcases). */
autoplay?: { question: string; loop?: boolean } | false;
className?: string;
}
const reduced = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const DEFAULT_ANSWER =
"Start with the problem, not the feature. Write one sentence on who it's for and what changes for them, then sketch the smallest version you could ship this week. I can help you scope it, draft the launch copy, or break it into tasks.";
type Msg = { id: number; q: string; words: string[]; shown: number; done: boolean };
/* ---------- tiny icons ---------- */
const I = { fill: "none", stroke: "currentColor", strokeWidth: 1.7, strokeLinecap: "round", strokeLinejoin: "round" } as const;
const Icon = {
plus: <path d="M12 6v12M6 12h12" {...I} />,
mic: (
<>
<rect x="9" y="4" width="6" height="10" rx="3" {...I} />
<path d="M6.5 11.5a5.5 5.5 0 0 0 11 0M12 17v3" {...I} />
</>
),
up: <path d="M12 18V7M7 11.5 12 6.5l5 5" {...I} />,
copy: (
<>
<rect x="8" y="8" width="11" height="11" rx="2.5" {...I} />
<path d="M15.5 8V6.5A2.5 2.5 0 0 0 13 4H6.5A2.5 2.5 0 0 0 4 6.5V13a2.5 2.5 0 0 0 2.5 2.5H8" {...I} />
</>
),
check: <path d="m6 12.5 4 4 8-9" {...I} />,
up_: <path d="M7 11v8H4.5v-8H7Zm0 0 3.6-6.2a1.7 1.7 0 0 1 3.1 1.2L13 9.5h5a2 2 0 0 1 2 2.3l-1 6a2 2 0 0 1-2 1.7H7" {...I} />,
down_: <path d="M7 13V5H4.5v8H7Zm0 0 3.6 6.2a1.7 1.7 0 0 0 3.1-1.2L13 14.5h5a2 2 0 0 0 2-2.3l-1-6A2 2 0 0 0 17 4.5H7" {...I} />,
share: <path d="M12 15V4M8 7.5 12 3.5l4 4M5 13v4.5A2.5 2.5 0 0 0 7.5 20h9a2.5 2.5 0 0 0 2.5-2.5V13" {...I} />,
retry: <path d="M19 12a7 7 0 1 1-2.1-5M19 4.5V9h-4.5" {...I} />,
chev: <path d="m7 10 5 5 5-5" {...I} />,
};
const Svg = ({ children, s = 16 }: { children: ReactNode; s?: number }) => (
<svg viewBox="0 0 24 24" width={s} height={s} aria-hidden="true" style={{ overflow: "visible" }}>
{children}
</svg>
);
/* a word that glows violet as it arrives, then settles white */
function Word({ w, still }: { w: string; still: boolean }) {
const ref = useRef<HTMLSpanElement>(null);
useLayoutEffect(() => {
if (!ref.current || still) return;
gsap.fromTo(
ref.current,
// colour, fade and a small rise only (a blur per word would re-render every frame)
{ opacity: 0, y: 5, color: "#e48bff" },
{ opacity: 1, y: 0, color: "#f4f1fa", duration: 0.7, ease: "power3.out" },
);
}, [still]);
return (
<span ref={ref} className="inline-block">
{w}
</span>
);
}
/* fades up into place when it first appears */
function FadeIn({ children, className }: { children: ReactNode; className?: string }) {
const ref = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
if (!ref.current || reduced()) return;
gsap.fromTo(ref.current, { opacity: 0, y: 4 }, { opacity: 1, y: 0, duration: 0.35, ease: "power2.out" });
}, []);
return (
<div ref={ref} className={className}>
{children}
</div>
);
}
/* an action that hops when you press it */
function Action({ label, children, onClick, active }: { label: string; children: ReactNode; onClick?: () => void; active?: boolean }) {
const ref = useRef<HTMLButtonElement>(null);
const hop = () => {
const el = ref.current;
if (!el || reduced()) return;
gsap.timeline()
.to(el, { scaleY: 0.75, scaleX: 1.2, duration: 0.08, ease: "power2.in" })
.to(el, { scaleY: 1.2, scaleX: 0.88, y: -3, duration: 0.14, ease: "power2.out" })
.to(el, { scaleY: 1, scaleX: 1, y: 0, duration: 0.5, ease: "elastic.out(1, 0.4)" });
};
return (
<button
ref={ref}
type="button"
aria-label={label}
data-action
onClick={() => {
hop();
onClick?.();
}}
className={`grid size-6 place-items-center rounded-md transition-colors duration-200 hover:bg-white/10 hover:text-white ${active ? "text-white" : "text-white/55"}`}
>
{children}
</button>
);
}
export function AiChatPanel({
title = "AI Assistant",
greeting = "What are you working on?",
placeholder = "Ask me anything",
respond,
width = 560,
height = 380,
autoplay = false,
className,
}: AiChatPanelProps) {
const [phase, setPhase] = useState<"empty" | "chat">("empty");
const [text, setText] = useState("");
const [thread, setThread] = useState<Msg[]>([]);
const [rated, setRated] = useState<Record<number, "up" | "down" | undefined>>({});
const [copied, setCopied] = useState<number | null>(null);
const cardRef = useRef<HTMLDivElement>(null);
const headRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLDivElement>(null);
const areaRef = useRef<HTMLTextAreaElement>(null);
const threadRef = useRef<HTMLDivElement>(null);
const blobs = useRef<(HTMLSpanElement | null)[]>([]);
const sendIcon = useRef<HTMLSpanElement>(null);
const flight = useRef<{ x: number; y: number; w: number; h: number } | null>(null);
const pulse = useRef<(amt: number) => void>(() => {});
const userTook = useRef(false);
const idRef = useRef(0);
const streamTimer = useRef<number | null>(null);
const still = useRef(false);
const pad = 18;
const geo = {
empty: { top: Math.round(height * 0.46), h: 78 },
chat: { top: height - pad - 44, h: 44 },
};
/* ---------- the aurora: blobs on springs, leaning to the cursor, pulsing ---------- */
useEffect(() => {
still.current = reduced();
const card = cardRef.current;
if (!card) return;
// base positions (fractions of the card) and how strongly each leans
const base = [
{ x: 0.78, y: 0.92, lean: 0.12, k: 40 },
{ x: 0.45, y: 1.02, lean: 0.08, k: 26 },
{ x: 0.12, y: 0.98, lean: 0.05, k: 18 },
{ x: 0.92, y: 0.55, lean: 0.1, k: 32 },
];
const b = base.map((p) => ({ ...p, cx: p.x, cy: p.y, vx: 0, vy: 0, s: 1, vs: 0 }));
const aim = { x: 0.5, y: 0.7 };
let glow = 0.85, tGlow = 0.85;
let t0 = 0;
pulse.current = (amt: number) => {
if (still.current) return;
b.forEach((p, i) => (p.vs += amt * (1.4 - i * 0.25)));
tGlow = Math.min(1.25, tGlow + amt * 0.25);
};
const tick = (time: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
t0 = time;
tGlow += (0.85 - tGlow) * Math.min(1, dt * 1.6);
glow += (tGlow - glow) * Math.min(1, dt * 8);
b.forEach((p, i) => {
// a slow drift so it's never static, plus the lean toward the cursor
const dx = Math.sin(t0 * (0.21 + i * 0.07) + i * 2) * 0.05, dy = Math.cos(t0 * (0.17 + i * 0.05) + i) * 0.04;
const tx = p.x + dx + (aim.x - 0.5) * p.lean * 2, ty = p.y + dy + (aim.y - 0.5) * p.lean * 1.4;
const c = 2 * 0.7 * Math.sqrt(p.k);
if (still.current) {
p.cx = tx;
p.cy = ty;
} else {
p.vx += (p.k * (tx - p.cx) - c * p.vx) * dt;
p.cx += p.vx * dt;
p.vy += (p.k * (ty - p.cy) - c * p.vy) * dt;
p.cy += p.vy * dt;
}
// each pulse swells the blob, which wobbles back
const ks = 120, cs = 2 * 0.3 * Math.sqrt(ks);
p.vs += (ks * (1 - p.s) - cs * p.vs) * dt;
p.s += p.vs * dt;
const el = blobs.current[i];
if (el) {
el.style.transform = `translate3d(${(p.cx * width).toFixed(1)}px,${(p.cy * height).toFixed(1)}px,0) translate(-50%,-50%) scale(${p.s.toFixed(3)})`;
el.style.opacity = Math.min(1, glow * (i === 3 ? 0.6 : 1)).toFixed(3);
}
});
};
gsap.ticker.add(tick);
const onMove = (e: PointerEvent) => {
const r = card.getBoundingClientRect();
aim.x = Math.max(-0.2, Math.min(1.2, (e.clientX - r.left) / r.width));
aim.y = Math.max(-0.2, Math.min(1.2, (e.clientY - r.top) / r.height));
};
const onLeave = () => {
aim.x = 0.5;
aim.y = 0.7;
};
card.addEventListener("pointermove", onMove);
card.addEventListener("pointerleave", onLeave);
return () => {
gsap.ticker.remove(tick);
card.removeEventListener("pointermove", onMove);
card.removeEventListener("pointerleave", onLeave);
};
}, [width, height]);
/* ---------- the greeting, word by word ---------- */
useLayoutEffect(() => {
const head = headRef.current;
if (!head) return;
const words = Array.from(head.children);
gsap.killTweensOf(words);
if (phase === "empty") {
if (still.current) gsap.set(words, { opacity: 1, y: 0, filter: "none", color: "#f4f1fa" });
else
gsap.fromTo(
words,
{ opacity: 0, y: 8, filter: "blur(6px)", color: "#d77bff" },
{ opacity: 1, y: 0, filter: "blur(0px)", color: "#f4f1fa", duration: 0.8, stagger: 0.08, ease: "power3.out", delay: 0.15 },
);
} else {
gsap.to(words, { opacity: 0, y: -10, filter: "blur(6px)", duration: 0.22, stagger: 0.025, ease: "power2.in" });
}
}, [phase]);
/* ---------- the input moves between its two homes, landing with a squash ---------- */
const first = useRef(true);
useLayoutEffect(() => {
const el = inputRef.current, area = areaRef.current;
if (!el || !area) return;
const g = geo[phase];
const ta = phase === "empty" ? { left: 14, right: 14, top: 12 } : { left: 42, right: 46, top: 12 };
if (first.current || still.current) {
first.current = false;
gsap.set(el, { top: g.top, height: g.h });
gsap.set(area, ta);
return;
}
gsap.killTweensOf([el, area]);
const tl = gsap.timeline();
tl.to(el, { top: g.top, height: g.h, duration: 0.75, ease: "elastic.out(1, 0.75)" }, 0)
.to(area, { ...ta, duration: 0.45, ease: "power3.out" }, 0)
.to(el, { scaleY: 0.9, scaleX: 1.025, duration: 0.1, ease: "power2.out", transformOrigin: "50% 100%" }, 0.24)
.to(el, { scaleY: 1, scaleX: 1, duration: 0.6, ease: "elastic.out(1, 0.4)" }, 0.34);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [phase, height]);
/* ---------- mic ↔ send arrow pops ---------- */
const hasText = text.trim().length > 0;
useLayoutEffect(() => {
if (!sendIcon.current || still.current) return;
gsap.fromTo(sendIcon.current, { scale: 0.5, rotation: hasText ? -90 : 90 }, { scale: 1, rotation: 0, duration: 0.5, ease: "elastic.out(1.1, 0.45)" });
}, [hasText]);
/* ---------- the question flies into its bubble ---------- */
useLayoutEffect(() => {
const from = flight.current;
const card = cardRef.current, list = threadRef.current;
if (!from || !card || !list) return;
flight.current = null;
const bubble = Array.from(list.querySelectorAll<HTMLElement>("[data-bubble]")).pop();
if (!bubble) return;
list.scrollTop = list.scrollHeight;
if (still.current) return;
const cr = card.getBoundingClientRect(), br = bubble.getBoundingClientRect();
const dx = from.x - (br.left - cr.left), dy = from.y - (br.top - cr.top);
gsap.set(bubble, { transformOrigin: "100% 50%" });
gsap.timeline()
.fromTo(bubble, { x: dx + (from.w - br.width), y: dy, opacity: 0.4 }, { x: 0, y: 0, opacity: 1, duration: 0.55, ease: "power3.inOut" }, 0)
// stretch along the flight, squash on landing, settle
.fromTo(bubble, { scaleX: 0.9, scaleY: 1 }, { scaleX: 1.12, scaleY: 0.86, duration: 0.25, ease: "power2.in" }, 0)
.to(bubble, { scaleX: 0.94, scaleY: 1.1, duration: 0.18, ease: "power2.out" }, 0.3)
.to(bubble, { scaleX: 1, scaleY: 1, duration: 0.6, ease: "elastic.out(1, 0.4)" }, 0.5);
}, [thread.length]);
/* ---------- streaming ---------- */
const stream = useCallback((id: number, answer: string) => {
const words = answer.split(/\s+/).filter(Boolean);
// nothing shows until the first word lands (the greeting has gone by then)
setThread((t) => t.map((m) => (m.id === id ? { ...m, words: [], shown: 0, done: false } : m)));
let i = 0;
const step = () => {
i++;
pulse.current(0.18);
setThread((t) => t.map((m) => (m.id === id ? { ...m, words, shown: i, done: i >= words.length } : m)));
const list = threadRef.current;
if (list) list.scrollTop = list.scrollHeight;
if (i < words.length) streamTimer.current = window.setTimeout(step, still.current ? 0 : 38 + Math.random() * 40);
};
streamTimer.current = window.setTimeout(step, 420);
}, []);
const send = useCallback(
async (q?: string) => {
const question = (q ?? text).trim();
if (!question) return;
// where the typed text sits now, so the bubble can fly from there
const card = cardRef.current, area = areaRef.current;
if (card && area) {
const cr = card.getBoundingClientRect(), ar = area.getBoundingClientRect();
flight.current = { x: ar.left - cr.left, y: ar.top - cr.top, w: Math.min(ar.width, question.length * 7.2), h: ar.height };
}
const id = ++idRef.current;
setText("");
setPhase("chat");
setThread((t) => [...t, { id, q: question, words: [], shown: 0, done: false }]);
pulse.current(0.9);
const answer = respond ? await respond(question) : DEFAULT_ANSWER;
stream(id, answer);
},
[text, respond, stream],
);
const reset = useCallback(() => {
if (streamTimer.current) window.clearTimeout(streamTimer.current);
setThread([]);
setRated({});
setText("");
setPhase("empty");
pulse.current(0.6);
}, []);
useEffect(() => () => void (streamTimer.current && window.clearTimeout(streamTimer.current)), []);
/* ---------- autoplay (showcases): types, sends, loops; stops when you take over ---------- */
const doneCount = thread.filter((m) => m.done).length;
useEffect(() => {
if (!autoplay || userTook.current) return;
let alive = true;
const timers: number[] = [];
const later = (ms: number, f: () => void) => timers.push(window.setTimeout(() => alive && !userTook.current && f(), ms));
if (phase === "empty" && thread.length === 0) {
const q = autoplay.question;
later(1100, () => {
let i = 0;
const typeNext = () => {
i++;
setText(q.slice(0, i));
pulse.current(0.22);
if (i < q.length) later(34 + Math.random() * 50, typeNext);
else later(450, () => sendRef.current(q));
};
typeNext();
});
} else if (autoplay.loop && doneCount > 0 && thread.every((m) => m.done)) {
later(3600, () => reset());
}
return () => {
alive = false;
timers.forEach((t) => window.clearTimeout(t));
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [autoplay && autoplay.question, phase, doneCount]);
const sendRef = useRef(send);
sendRef.current = send;
// a real person pressing or typing takes over from the autoplay
const takeOver = (e?: { nativeEvent?: Event } | Event) => {
const ev = e && "nativeEvent" in e ? e.nativeEvent : (e as Event | undefined);
if (ev && !ev.isTrusted) return;
if (!autoplay || userTook.current) return;
userTook.current = true;
};
const onKey = (e: KeyboardEvent<HTMLTextAreaElement>) => {
if (e.key === "Enter" && !e.shiftKey) {
e.preventDefault();
send();
}
};
const copy = (m: Msg) => {
navigator.clipboard?.writeText(m.words.join(" ")).catch(() => {});
setCopied(m.id);
window.setTimeout(() => setCopied((c) => (c === m.id ? null : c)), 1400);
};
const ring = {
WebkitMask: "linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)",
WebkitMaskComposite: "xor",
mask: "linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0)",
padding: 1,
} as const;
return (
<div
ref={cardRef}
className={["relative isolate overflow-hidden text-[#f4f1fa] select-none", className].filter(Boolean).join(" ")}
style={{ width, height, borderRadius: 22, background: "linear-gradient(180deg, #1c1824 0%, #17121f 100%)", boxShadow: "0 1px 2px rgba(0,0,0,.4), 0 18px 50px rgba(0,0,0,.45)" }}
onPointerDown={(e) => takeOver(e)}
>
{/* the aurora inside the glass */}
<div aria-hidden="true" className="pointer-events-none absolute inset-0 -z-10">
{[
{ c: "#e01cff", s: 0.62 },
{ c: "#8a2cff", s: 0.72 },
{ c: "#4a2dff", s: 0.6 },
{ c: "#b51cff", s: 0.42 },
].map((b, i) => (
<span
key={i}
ref={(el) => void (blobs.current[i] = el)}
className="absolute top-0 left-0 rounded-full will-change-[transform,opacity]"
style={{ width: width * b.s, height: width * b.s * 0.62, background: b.c, filter: `blur(${Math.round(width * 0.075)}px)` }}
/>
))}
{/* frost over the light, darker toward the top so the text stays crisp */}
<span className="absolute inset-0" style={{ background: "linear-gradient(180deg, rgba(22,17,30,.94) 0%, rgba(22,17,30,.62) 45%, rgba(22,17,30,.18) 100%)" }} />
</div>
{/* the glass edge: a hairline that catches the light at the bottom */}
<span
aria-hidden="true"
className="pointer-events-none absolute inset-0"
style={{ ...ring, borderRadius: 22, background: "linear-gradient(180deg, rgba(255,255,255,.1), rgba(214,92,255,.18) 60%, rgba(236,120,255,.7))" }}
/>
{/* header: new chat */}
<button
type="button"
onClick={(e) => {
takeOver(e);
reset();
}}
className="group/t absolute top-3.5 left-4 z-10 flex items-center gap-1 rounded-md px-1.5 py-1 text-[12px] font-medium text-white/80 transition-colors hover:bg-white/8 hover:text-white"
aria-label={`${title}: new chat`}
>
{title}
<span className="transition-transform duration-300 group-hover/t:translate-y-0.5">
<Svg s={13}>{Icon.chev}</Svg>
</span>
</button>
{/* greeting */}
<div
ref={headRef}
aria-hidden={phase !== "empty"}
className="pointer-events-none absolute inset-x-0 text-center font-medium tracking-[-0.01em]"
style={{ top: geo.empty.top - 52, fontSize: Math.round(Math.min(26, width * 0.042)) }}
>
{greeting.split(" ").map((w, i) => (
<span key={`${w}${i}`} className="inline-block">
{w}
</span>
))}
</div>
{/* the conversation */}
<div
ref={threadRef}
className="absolute overflow-y-auto overscroll-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
style={{
left: pad,
right: pad,
top: 46,
bottom: pad + 44 + 12,
visibility: phase === "chat" ? "visible" : "hidden",
WebkitMaskImage: "linear-gradient(180deg, transparent 0, #000 14px, #000 calc(100% - 10px), transparent)",
maskImage: "linear-gradient(180deg, transparent 0, #000 14px, #000 calc(100% - 10px), transparent)",
}}
aria-live="polite"
>
{thread.map((m) => (
<div key={m.id} className="mb-4 flex flex-col">
<div
data-bubble
className="relative max-w-[78%] self-end rounded-full px-3.5 py-1.5 text-[12.5px] leading-snug will-change-transform"
style={{ background: "linear-gradient(90deg, rgba(110,60,255,.55), rgba(196,70,255,.55))", boxShadow: "inset 0 0 0 1px rgba(255,255,255,.22), inset 0 1px 0 rgba(255,255,255,.25)" }}
>
{m.q}
</div>
{/* the answer arrives once it starts streaming (never over the greeting) */}
{m.words.length > 0 && (
<FadeIn>
<div className="mt-3 text-[11.5px] font-medium text-white/55">Answer:</div>
<p className="mt-1.5 text-[13px] leading-[1.55]">
{m.words.slice(0, m.shown).map((w, i) => (
<Word key={i} w={w} still={still.current} />
))}
{!m.done && <span className="inline-block h-[1em] w-[2px] translate-y-[2px] animate-pulse rounded-full bg-[#e48bff] align-baseline" />}
</p>
</FadeIn>
)}
{m.done && (
<div className="mt-2 flex gap-0.5" data-actions>
<Action label="Copy answer" onClick={() => copy(m)} active={copied === m.id}>
<Svg s={14}>{copied === m.id ? Icon.check : Icon.copy}</Svg>
</Action>
<Action label="Good answer" active={rated[m.id] === "up"} onClick={() => setRated((r) => ({ ...r, [m.id]: r[m.id] === "up" ? undefined : "up" }))}>
<Svg s={14}>{Icon.up_}</Svg>
</Action>
<Action label="Bad answer" active={rated[m.id] === "down"} onClick={() => setRated((r) => ({ ...r, [m.id]: r[m.id] === "down" ? undefined : "down" }))}>
<Svg s={14}>{Icon.down_}</Svg>
</Action>
<Action label="Share" onClick={() => navigator.share?.({ text: m.words.join(" ") }).catch(() => {})}>
<Svg s={14}>{Icon.share}</Svg>
</Action>
<Action
label="Try again"
onClick={async () => {
pulse.current(0.7);
stream(m.id, respond ? await respond(m.q) : DEFAULT_ANSWER);
}}
>
<Svg s={14}>{Icon.retry}</Svg>
</Action>
</div>
)}
</div>
))}
</div>
{/* the input */}
<div
ref={inputRef}
className="absolute will-change-transform"
style={{
left: pad,
right: pad,
top: geo.empty.top,
height: geo.empty.h,
borderRadius: 14,
background: "linear-gradient(180deg, rgba(255,255,255,.13), rgba(255,255,255,.08))",
boxShadow: "inset 0 1px 0 rgba(255,255,255,.14), inset 0 0 0 1px rgba(255,255,255,.07), 0 6px 18px rgba(10,4,20,.25)",
}}
onClick={() => areaRef.current?.focus()}
>
<textarea
ref={areaRef}
value={text}
rows={1}
placeholder={placeholder}
aria-label={placeholder}
onChange={(e) => {
takeOver(e);
setText(e.target.value);
pulse.current(0.22);
}}
onKeyDown={onKey}
className="absolute resize-none overflow-hidden bg-transparent text-[13px] leading-[20px] text-white outline-none placeholder:text-white/40"
style={{ left: 14, right: 14, top: 12, height: 20 }}
/>
<button
type="button"
aria-label="Attach"
className="absolute bottom-2 left-2 grid size-7 place-items-center rounded-full text-white/75 transition-colors hover:bg-white/10 hover:text-white"
>
<Svg s={16}>{Icon.plus}</Svg>
</button>
<button
type="button"
aria-label={hasText ? "Send" : "Voice"}
onClick={(e) => {
e.stopPropagation();
takeOver(e);
if (hasText) send();
}}
className={`absolute right-2 bottom-2 grid size-7 place-items-center rounded-full transition-colors duration-300 ${hasText ? "bg-white text-[#1a1222]" : "text-white/75 hover:bg-white/10"}`}
>
<span ref={sendIcon} className="grid place-items-center">
<Svg s={16}>{hasText ? Icon.up : Icon.mic}</Svg>
</span>
</button>
</div>
</div>
);
}
export default AiChatPanel;
One prompt, any AI agent
Paste into Claude Code, Codex, Cursor or Windsurf. It carries your tweaks and the full source, so the agent installs it exactly.
Props
8 propsrespond(question: string) => string | Promise<string>Produce the answer; it streams in word by word.titlestringHeader (click it for a new chat).default "AI Assistant"default "AI Assistant"greetingstringThe empty-state greeting.default "What are you working on?"default "What are you working on?"placeholderstringInput placeholder.default "Ask me anything"default "Ask me anything"widthnumberCard width, px.default 560default 560heightnumberCard height, px.default 380default 380autoplay{ question: string; loop?: boolean } | falseType and send a question by itself (for showcases).default falsedefault falseclassNamestringExtra classes.