Thinking UI

Status Pill

Pairs any agent-state loader with a shimmering label and rolling dots.

Code

components/thinking-ui/status-pill.tsx
"use client";

import { AnimatePresence, motion } from "motion/react";
import type { ReactNode } from "react";
import { TextShimmer } from "@/components/thinking-ui/text-shimmer";
import { useMotion } from "@/lib/motion";
import { cn } from "@/lib/utils";

export type StatusPillProps = {
  /** The animated indicator, e.g. <ThinkingSphere />. */
  icon: ReactNode;
  /** What the agent is doing: "Thinking", "Searching the web"… */
  label: string;
  /** Shimmer the label and run the trailing dots. */
  active?: boolean;
  size?: "sm" | "md" | "lg";
  className?: string;
};

const sizes = {
  sm: { pill: "h-9 gap-2 pl-1.5 pr-3.5 text-sm", icon: "size-6" },
  md: { pill: "h-12 gap-2.5 pl-2 pr-5 text-md", icon: "size-8" },
  lg: { pill: "h-16 gap-3.5 pl-3 pr-7 text-xl", icon: "size-11" },
};

/** An agent-state indicator with a label: icon on the left, shimmering status text, rolling dots. */
export function StatusPill({ icon, label, active = true, size = "md", className }: StatusPillProps) {
  const m = useMotion();
  const s = sizes[size];

  return (
    <motion.div
      layout
      role="status"
      aria-label={`${label}${active ? "…" : ""}`}
      className={cn(
        "inline-flex items-center rounded-full bg-[color-mix(in_oklab,var(--surface-panel)_80%,transparent)] shadow-[inset_0_0_0_1px_var(--border-subtle)]",
        s.pill,
        className,
      )}
      style={{ borderRadius: 9999 }}
      transition={m.spring("layout")}
    >
      <motion.span layout="position" aria-hidden className={cn("grid shrink-0 place-items-center", s.icon)}>
        {icon}
      </motion.span>
      <motion.span layout="position" aria-hidden className="relative inline-flex items-baseline whitespace-nowrap text-fg-tertiary">
        <AnimatePresence mode="popLayout" initial={false}>
          <motion.span key={label} className="block" {...m.swap()}>
            {active ? <TextShimmer duration={2.2}>{label}</TextShimmer> : label}
          </motion.span>
        </AnimatePresence>
        {active && <Ellipsis />}
      </motion.span>
    </motion.div>
  );
}

/** Four dots that fill in one by one, then reset: reads as ongoing without a spinner. */
function Ellipsis() {
  const m = useMotion();
  return (
    <span className="ml-px inline-flex">
      {[0, 1, 2, 3].map((i) => (
        <motion.span
          key={i}
          className="text-fg-muted"
          animate={m.reduce ? { opacity: 0.6 } : { opacity: [0.15, 1, 1, 0.15] }}
          transition={{ duration: 1.6 * m.scale, times: [0, 0.2, 0.75, 1], repeat: Infinity, delay: i * 0.18 * m.scale, ease: "easeOut" }}
        >
          .
        </motion.span>
      ))}
    </span>
  );
}

Motion notes

  • The label swaps with a short blur-slide when the agent moves to a new step, and the pill resizes on a layout spring so it never jumps.
  • Four trailing dots fill in one by one and reset: it reads as ongoing work without adding a second spinner next to the icon.
  • Three sizes tuned to sit inline in a chat row (sm), under a message (md) or as a hero status (lg).

Installation

  1. 1

    Install dependencies

    Terminal
    npm install motion clsx tailwind-merge
  2. 2

    Add the design tokens and motion system (once per project)

    Copy styles/tokens/*, lib/motion.tsx and lib/utils.ts from Get started.

  3. 3

    Add the components it uses

    Text Shimmer

  4. 4

    Paste the source into components/thinking-ui/status-pill.tsx

    Copy it from the Code tab, or use Copy prompt to let your coding agent do all of this.

Usage

Example
<StatusPill icon={<ThinkingSphere size={32} />} label="Thinking" />

Props

PropTypeDefaultDescription
iconReactNode—The animated indicator, e.g. <ThinkingSphere />.
labelstring—What the agent is doing.
activebooleantrueShimmer the label and run the dots.
size"sm" | "md" | "lg""md"Pill size.