Components74 / 118
AI Status Pill
A liquid-glass capsule that shows what the AI is doing, with a living fill for each state: an aurora while thinking, smoky light behind fluted glass while searching, two colours swirling while planning, ink streaks while writing. A new state flows in through a liquid front; the pill springs to its width and the dots bounce.
AIAIStatusStatusLiquid glassLiquid glassWebGLWebGLSquash & stretchSquash & stretchGSAPGSAP
Hover across the glassClick for the next state
Tweak
LIVELIVEState
State
Cycle through states
Look
68px
Usage
Follows your tweaks.
usage.tsx
import { AiStatusPill } from "@/components/inreact/ai-status-pill";
export function Status({ step }: { step: "thinking" | "searching" | "planning" | "writing" }) {
return <AiStatusPill state={step} size={68} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/ai-status-pill.jsonOr copy the source
Install the dependencies, then save this as components/inreact/ai-status-pill.tsx.
terminal
npm install gsap threecomponents/inreact/ai-status-pill.tsx
"use client";
import { gsap } from "gsap";
import * as THREE from "three";
import { useEffect, useLayoutEffect, useRef, useState } from "react";
/**
* AI Status Pill: a glass capsule that shows what the AI is doing.
*
* A liquid-glass pill (bevelled edge that bends what's inside it, with a
* colour fringe and soft rim highlights) filled with a living light that is
* different for each state: an aurora ribbon while thinking, smoky light
* behind fluted glass while searching, two colours swirling against each other
* while planning, ink streaks while writing. Change the state and the new
* fill flows in through a liquid front with a bright seam (no cross-fade); the
* pill springs to its new width, squashing as it goes, the label rolls over
* letter by letter and the three dots keep bouncing. Hover and a lens of
* thicker glass follows your cursor while the light runs faster. WebGL (three)
* + GSAP.
*
* <AiStatusPill state={busy ? "thinking" : "writing"} />
*/
export type AiState = "thinking" | "searching" | "planning" | "writing";
export interface AiStatusPillProps {
state?: AiState;
/** Override the label (the dots are added for you). */
label?: string;
/** Height, px. */
size?: number;
onClick?: () => void;
className?: string;
}
const LABELS: Record<AiState, string> = { thinking: "Thinking", searching: "Searching", planning: "Planning", writing: "Writing" };
const ORDER: AiState[] = ["thinking", "searching", "planning", "writing"];
const reduced = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const VERT = /* glsl */ `
varying vec2 vUv;
void main() { vUv = uv; gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); }`;
const FRAG = /* glsl */ `
precision highp float;
varying vec2 vUv;
uniform vec2 uRes; // canvas, css px
uniform vec2 uPill; // pill width, height (css px)
uniform vec2 uSq; // squash / stretch
uniform float uTime;
uniform vec2 uMouse; // css px from the centre
uniform float uHover;
uniform float uFrom;
uniform float uTo;
uniform float uMix;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
float noise(vec2 p) {
vec2 i = floor(p), f = fract(p);
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(mix(hash(i), hash(i + vec2(1, 0)), u.x), mix(hash(i + vec2(0, 1)), hash(i + vec2(1, 1)), u.x), u.y);
}
float fbm(vec2 p) {
float a = 0.5, s = 0.0;
for (int i = 0; i < 4; i++) { s += a * noise(p); p = p * 2.03 + 7.1; a *= 0.5; }
return s;
}
// thinking: an aurora ribbon waving through deep indigo
vec3 thinking(vec2 q, float t) {
vec3 base = vec3(0.03, 0.008, 0.09) * (1.0 + 0.4 * smoothstep(0.8, -0.2, q.y));
float y0 = -0.22 + 0.2 * sin(q.x * 2.1 + t * 1.2) + 0.07 * sin(q.x * 5.3 - t * 2.0);
float band = exp(-pow((q.y - y0) / 0.17, 2.0));
float x = q.x * 0.5 + 0.5;
vec3 c = mix(vec3(1.0, 0.52, 0.08), vec3(0.45, 1.0, 0.35), smoothstep(0.0, 0.42, x));
c = mix(c, vec3(0.15, 0.85, 1.0), smoothstep(0.38, 0.62, x));
c = mix(c, vec3(0.78, 0.2, 1.0), smoothstep(0.6, 0.95, x));
float below = smoothstep(y0 + 0.05, y0 - 0.75, q.y);
return base + c * band * 1.2 + below * vec3(0.56, 0.52, 0.62) * 0.8 + c * below * 0.1;
}
// searching: smoky warm light seen through fluted (ribbed) glass
vec3 searching(vec2 q, float t, float aspect) {
float k = 3.2 * aspect;
float cell = q.x * k;
float f = fract(cell) - 0.5;
float xs = (floor(cell) + 0.5 - f * 0.65) / k; // each rib flips what's behind it
float n = fbm(vec2(xs * 1.4 + t * 0.32, q.y * 1.3 - t * 0.12));
float m = fbm(vec2(xs * 2.6 - t * 0.2, q.y * 2.0 + 3.0));
vec3 c = mix(vec3(0.03, 0.03, 0.035), vec3(0.82, 0.76, 0.72), smoothstep(0.36, 0.76, n));
c += vec3(0.55, 0.28, 0.08) * smoothstep(0.62, 0.9, m) * 0.6;
c *= 0.82 + 0.18 * smoothstep(0.5, 0.2, abs(f)); // rib edges darken a touch
return c;
}
// planning: two colours swirling against each other
vec3 planning(vec2 q, float t) {
vec2 w = q + 0.28 * vec2(fbm(q * 1.4 + vec2(t * 0.25, 0.0)) - 0.5, fbm(q * 1.4 - vec2(0.0, t * 0.22)) - 0.5) * 2.0;
float s = w.x + 0.32 * sin(w.y * 2.6 + t * 0.9);
vec3 L = mix(vec3(0.08, 0.16, 0.85), vec3(0.08, 0.82, 0.96), smoothstep(-1.0, -0.15, w.x));
vec3 R = mix(vec3(0.97, 0.32, 0.42), vec3(0.74, 0.02, 0.1), smoothstep(0.05, 1.0, w.x));
return mix(L, R, smoothstep(-0.1, 0.1, s));
}
// writing: ink streaks flowing through deep teal
vec3 writing(vec2 q, float t) {
float w = fbm(q * vec2(1.2, 2.4) + vec2(t * 0.25, 0.0));
float l = sin((q.y * 2.6 + w * 1.8 + q.x * 0.35 - t * 0.7) * 3.14159);
float streak = pow(0.5 + 0.5 * l, 22.0);
vec3 c = vec3(0.015, 0.06, 0.055) + vec3(0.03, 0.2, 0.16) * w * smoothstep(0.6, -0.6, q.y);
return c + streak * 0.85 * mix(vec3(0.4, 0.95, 0.7), vec3(0.85, 1.0, 0.6), 0.5 + 0.5 * q.x);
}
vec3 fill(float id, vec2 q, float t, float aspect) {
if (id < 0.5) return thinking(q, t);
if (id < 1.5) return searching(q, t, aspect);
if (id < 2.5) return planning(q, t);
return writing(q, t);
}
vec3 scene(vec2 q, float t, float aspect) {
// the new state flows in from the left through a liquid front
float xw = mix(-1.6, 1.6, uMix) + (noise(vec2(q.y * 2.5, t * 1.5)) - 0.5) * 0.45;
float k = smoothstep(xw + 0.12, xw - 0.12, q.x);
vec3 a = fill(uFrom, q, t, aspect);
vec3 c = k > 0.001 ? mix(a, fill(uTo, q, t, aspect), k) : a;
float seam = exp(-pow((q.x - xw) / 0.07, 2.0)) * step(0.001, uMix) * step(uMix, 0.999);
return c + seam * vec3(1.0, 0.97, 1.0) * 0.55;
}
void main() {
vec2 p = (vUv - 0.5) * uRes;
float r = uPill.y * 0.5 * uSq.y;
float hw = max(r, uPill.x * 0.5 * uSq.x);
float cx = hw - r;
vec2 qd = vec2(max(abs(p.x) - cx, 0.0), p.y);
float d = length(qd) - r;
float mask = smoothstep(0.8, -0.8, d);
// soft shadow under the pill
vec2 ps = p - vec2(0.0, -r * 0.22);
float ds = length(vec2(max(abs(ps.x) - cx, 0.0), ps.y)) - r;
float shadow = exp(-max(ds, 0.0) / (r * 0.38)) * 0.42 * smoothstep(r * 0.8, -r * 0.2, ds);
if (mask <= 0.0) { gl_FragColor = vec4(0.0, 0.0, 0.0, shadow); return; }
// the glass: a bevel that bends what's behind it, with a colour fringe
vec2 n = abs(p.x) > cx ? normalize(vec2(sign(p.x) * (abs(p.x) - cx), p.y) + 1e-5) : vec2(0.0, sign(p.y));
float bev = r * 0.62;
float tt = clamp(-d / bev, 0.0, 1.0);
float slope = pow(1.0 - tt, 1.6);
vec2 off = -n * slope * r * 0.5;
// a lens of thicker glass under the cursor
vec2 m = p - uMouse;
float lens = exp(-dot(m, m) / (r * r * 1.3)) * uHover;
off += -m * lens * 0.24;
float aspect = hw / r;
float t = uTime;
vec2 qs = (p + off) / vec2(hw, r);
vec2 fr = n * slope * 0.03;
vec3 col;
col.r = scene(qs + fr, t, aspect).r;
col.g = scene(qs, t, aspect).g;
col.b = scene(qs - fr, t, aspect).b;
// thickness: the edge of the glass darkens, then catches the light at the rim
col *= mix(0.62, 1.0, smoothstep(0.0, 0.55, tt));
float rim = pow(1.0 - tt, 5.0);
col += rim * (max(n.y, 0.0) * 0.95 + max(-n.y, 0.0) * 0.4 + 0.12) * vec3(1.0);
// a broad soft sheen across the top
col += 0.07 * smoothstep(0.15, 0.95, p.y / r) * (1.0 - rim);
col += lens * 0.06;
float a = mask + shadow * (1.0 - mask);
gl_FragColor = vec4(col * mask, a);
}`;
export function AiStatusPill({ state = "thinking", label, size = 60, onClick, className }: AiStatusPillProps) {
const rootRef = useRef<HTMLButtonElement>(null);
const hostRef = useRef<HTMLDivElement>(null);
const measureRef = useRef<HTMLSpanElement>(null);
const labelsRef = useRef<HTMLSpanElement>(null);
const dotsRef = useRef<HTMLSpanElement>(null);
const api = useRef<{ setState: (s: AiState) => void; setWidth: (w: number) => void } | null>(null);
const text = label ?? LABELS[state];
const [shown, setShown] = useState([{ key: 0, text }]);
const keyRef = useRef(0);
const H = size;
const fs = Math.round(H * 0.34);
const padX = Math.round(H * 0.55);
const pad = Math.round(H * 0.32); // canvas margin, for squash and the shadow
const maxW = Math.round(H * 6.5);
/* ---------- the glass (WebGL) ---------- */
useEffect(() => {
const host = hostRef.current, root = rootRef.current;
if (!host || !root) return;
const still = reduced();
const CW = maxW + pad * 2, CH = H + pad * 2;
const pr = Math.min(2, window.devicePixelRatio || 1);
const canvas = document.createElement("canvas");
canvas.style.cssText = `position:absolute;left:50%;top:50%;width:${CW}px;height:${CH}px;transform:translate(-50%,-50%);pointer-events:none;`;
host.appendChild(canvas);
let renderer: THREE.WebGLRenderer;
try {
renderer = new THREE.WebGLRenderer({ canvas, alpha: true, premultipliedAlpha: true, antialias: false });
} catch {
canvas.remove();
return;
}
renderer.setPixelRatio(pr);
renderer.setSize(CW, CH, false);
renderer.setClearColor(0x000000, 0);
const scene = new THREE.Scene();
const camera = new THREE.OrthographicCamera(0, CW, CH, 0, -1, 1);
const mat = new THREE.ShaderMaterial({
vertexShader: VERT,
fragmentShader: FRAG,
transparent: true,
depthTest: false,
blending: THREE.NoBlending,
uniforms: {
uRes: { value: new THREE.Vector2(CW, CH) },
uPill: { value: new THREE.Vector2(H * 3, H) },
uSq: { value: new THREE.Vector2(1, 1) },
uTime: { value: 0 },
uMouse: { value: new THREE.Vector2(0, 0) },
uHover: { value: 0 },
uFrom: { value: ORDER.indexOf(state) },
uTo: { value: ORDER.indexOf(state) },
uMix: { value: 0 },
},
});
const quad = new THREE.Mesh(new THREE.PlaneGeometry(CW, CH), mat);
quad.position.set(CW / 2, CH / 2, 0);
scene.add(quad);
renderer.compile(scene, camera);
const u = mat.uniforms;
// springs: width, jelly, hover, the lens
const st = { w: H * 3, vw: 0, tw: H * 3, s: 0, vs: 0, hov: 0, thov: 0, mx: 0, my: 0, tmx: 0, tmy: 0, time: Math.random() * 10 };
let mixTween: gsap.core.Tween | null = null;
api.current = {
setWidth: (w) => {
st.tw = Math.min(maxW, w);
if (st.w === H * 3 && st.vw === 0) st.w = st.tw; // first measure: no animation
},
setState: (s) => {
const to = ORDER.indexOf(s);
if (to === u.uTo.value && u.uMix.value === 0) return;
mixTween?.kill();
// if a flow was mid-way, settle on whichever state was winning
if (u.uMix.value > 0.5) u.uFrom.value = u.uTo.value;
u.uTo.value = to;
if (still) {
u.uFrom.value = to;
u.uMix.value = 0;
return;
}
u.uMix.value = 0;
mixTween = gsap.to(u.uMix, {
value: 1,
duration: 1.05,
ease: "power2.inOut",
onComplete: () => {
u.uFrom.value = to;
u.uMix.value = 0;
},
});
st.vs += 1.6; // a little pop as it changes
},
};
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30);
st.time += dt * (still ? 0 : 1 + st.hov * 0.9);
const h = dt / 2;
for (let i = 0; i < 2; i++) {
if (still) {
st.w = st.tw;
st.s = 0;
st.hov = st.thov;
break;
}
const k = 170, c = 2 * 0.55 * Math.sqrt(k);
st.vw += (k * (st.tw - st.w) - c * st.vw) * h;
st.w += st.vw * h;
// jelly: kicked by width changes (grows → squashes flat), wobbles back
const ks = 380, cs = 2 * 0.22 * Math.sqrt(ks);
st.vs += (-ks * st.s - cs * st.vs) * h - st.vw * 0.0009;
st.s += st.vs * h;
st.hov += (st.thov - st.hov) * Math.min(1, h * 7);
st.mx += (st.tmx - st.mx) * Math.min(1, h * 12);
st.my += (st.tmy - st.my) * Math.min(1, h * 12);
}
const s = Math.max(-0.12, Math.min(0.12, st.s));
u.uPill.value.set(st.w, H);
u.uSq.value.set(1 + s * 0.5, 1 - s);
u.uTime.value = st.time;
u.uHover.value = st.hov;
u.uMouse.value.set(st.mx, st.my);
root.style.width = `${st.w.toFixed(1)}px`;
renderer.render(scene, camera);
};
gsap.ticker.add(tick);
let box = root.getBoundingClientRect();
const onEnter = () => {
box = root.getBoundingClientRect();
st.thov = 1;
};
const onMove = (e: PointerEvent) => {
st.tmx = e.clientX - (box.left + box.width / 2);
st.tmy = -(e.clientY - (box.top + box.height / 2));
};
const onLeave = () => (st.thov = 0);
const onDown = () => {
if (!still) st.vs -= 2.4;
};
const onUp = () => {
if (!still) st.vs += 1.6;
};
root.addEventListener("pointerenter", onEnter);
root.addEventListener("pointermove", onMove);
root.addEventListener("pointerleave", onLeave);
root.addEventListener("pointerdown", onDown);
root.addEventListener("pointerup", onUp);
return () => {
gsap.ticker.remove(tick);
mixTween?.kill();
root.removeEventListener("pointerenter", onEnter);
root.removeEventListener("pointermove", onMove);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("pointerdown", onDown);
root.removeEventListener("pointerup", onUp);
api.current = null;
mat.dispose();
quad.geometry.dispose();
renderer.dispose();
canvas.remove();
};
// the state is pushed in below; this sets up once per size
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [H, maxW, pad]);
/* ---------- state changes: the fill flows, the width springs, the label rolls ---------- */
useLayoutEffect(() => {
api.current?.setState(state);
}, [state]);
useLayoutEffect(() => {
// measure the label (plus the dots) for the pill's width
const m = measureRef.current, dots = dotsRef.current;
if (m) api.current?.setWidth(m.offsetWidth + (dots?.offsetWidth ?? 0) + padX * 2);
if (shown[shown.length - 1].text === text) return;
keyRef.current += 1;
setShown((s) => [...s.slice(-1), { key: keyRef.current, text }]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [text, padX]);
useLayoutEffect(() => {
const box = labelsRef.current;
if (!box) return;
const spans = Array.from(box.children) as HTMLElement[];
const still = reduced();
const incoming = spans[spans.length - 1], outgoing = spans.length > 1 ? spans[0] : null;
if (outgoing) {
const letters = Array.from(outgoing.children);
if (still) setShown((s) => s.slice(-1));
else
gsap.to(letters, {
y: H * 0.3,
opacity: 0,
filter: "blur(3px)",
duration: 0.2,
stagger: 0.014,
ease: "power2.in",
onComplete: () => setShown((s) => s.slice(-1)),
});
}
if (incoming && outgoing && !still) {
gsap.fromTo(
Array.from(incoming.children),
{ y: -H * 0.32, opacity: 0, filter: "blur(3px)" },
{ y: 0, opacity: 1, filter: "blur(0px)", duration: 0.55, stagger: 0.03, ease: "back.out(2.2)", delay: 0.24, clearProps: "filter" },
);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [shown.length, shown[shown.length - 1]?.key]);
/* ---------- the three dots bounce, squashing as they land ---------- */
useEffect(() => {
const dots = dotsRef.current;
if (!dots || reduced()) return;
const els = Array.from(dots.children);
const tl = gsap.timeline({ repeat: -1, repeatDelay: 0.25 });
els.forEach((el, i) => {
tl.to(el, { y: -H * 0.1, scaleY: 1.3, scaleX: 0.8, duration: 0.18, ease: "power2.out", transformOrigin: "50% 100%" }, i * 0.12)
.to(el, { y: 0, scaleY: 1, scaleX: 1, duration: 0.16, ease: "power2.in" }, i * 0.12 + 0.18)
.to(el, { scaleY: 0.65, scaleX: 1.35, duration: 0.06, ease: "power1.out" }, i * 0.12 + 0.34)
.to(el, { scaleY: 1, scaleX: 1, duration: 0.3, ease: "elastic.out(1, 0.4)" }, i * 0.12 + 0.4);
});
return () => void tl.kill();
}, [H]);
return (
<button
ref={rootRef}
type="button"
onClick={onClick}
aria-live="polite"
aria-label={`${text}…`}
className={["relative inline-grid shrink-0 select-none place-items-center outline-none [-webkit-tap-highlight-color:transparent] focus-visible:ring-2 focus-visible:ring-white/30", className].filter(Boolean).join(" ")}
style={{ height: H, width: H * 3, borderRadius: H }}
>
<div ref={hostRef} aria-hidden="true" className="pointer-events-none absolute inset-0" />
<span ref={measureRef} aria-hidden="true" className="pointer-events-none invisible absolute font-semibold whitespace-nowrap" style={{ fontSize: fs }}>
{text}
</span>
<span aria-hidden="true" className="relative flex items-baseline font-semibold whitespace-nowrap text-white [text-shadow:0_1px_8px_rgba(0,0,0,.35)]" style={{ fontSize: fs, letterSpacing: "0.005em" }}>
<span ref={labelsRef} className="relative inline-grid">
{shown.map((s) => (
<span key={s.key} className="col-start-1 row-start-1 inline-flex justify-center">
{Array.from(s.text).map((ch, i) => (
<span key={i} className="inline-block" style={{ whiteSpace: "pre" }}>
{ch}
</span>
))}
</span>
))}
</span>
<span ref={dotsRef} className="inline-flex">
{[0, 1, 2].map((i) => (
<span key={i} className="inline-block">
.
</span>
))}
</span>
</span>
</button>
);
}
export default AiStatusPill;
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
5 propsstate"thinking" | "searching" | "planning" | "writing"What the AI is doing.default "thinking"default "thinking"labelstringOverride the label (dots are added).sizenumberHeight, px.default 60default 60onClick() => voidClick handler.classNamestringExtra classes.