Skip to content
Browse documentation

A pill for something that takes a moment: a ring turns while it runs, and when it’s done a ribbon of light scans the pill and the words change under it.

Used forSmart homeSync and uploadConnectionsDeploys and jobs

Install with the shadcn CLI

$ npx shadcn@latest add https://hairlineui.com/r/status-capsule.json

Registered the namespace? Then it’s shadcn add @hairline/status-capsule. Set it up

Templates

Need the whole page?

61 Next.js landing pages, each designed from scratch. Try any of them live; one is $39, all of them $159, and 6 are free.

All 61 templates

Where it’s used

  • Smart home

    A lock turning, a garage closing, a scene running on a device.

  • Sync and upload

    A photo library, a backup or an import that takes a while.

  • Connections

    Linking a bank, a calendar or an integration, with the history under View.

  • Deploys and jobs

    A release or a long job in a header, finishing in place.

What it handles for you

A spinner that swaps for a tick doesn’t mark the moment something finished, and its history usually lives on another screen.

Instead of wiring upstatus pillprogress toastloading badgesuccess toastactivity log popover
  1. Four states

    Idle, working, done and failed, from one status prop.

  2. The finish

    A ribbon of light scans the pill and the words change under it.

  3. Stays lit

    The rim keeps its light while the status is done.

  4. History in place

    View grows the pill into its log, with your action at the foot.

  5. Failure

    A red cross, one shake, and your action offered again to retry.

  6. Screen readers

    Done and failed are announced once, with the new words.

Overview

Locking a door, syncing a library, connecting a bank: most apps swap a spinner for a green tick and the moment it worked goes by unseen. Status capsule is one pill that carries the whole job. Idle, it offers your action. Working, a fine ring turns at its end. Done, a ribbon of azure light scans it from left to right, catching the top and bottom edges as it passes, with starlight dust trailing behind; under it the badge turns into a check and the words change, and the pill keeps its light in the rim (colour bleeding in from the corners and a fine prismatic bezel) for as long as it stays done. View grows the same pill into the history below it, with your follow-up action at the foot. If it fails, the badge turns red, the pill gives one shake and your action is offered again.

States

idle
Your icon on a primary badge and your action at the end.
working
A ring turns at the end every 900ms. Changes to the words show straight away, so a count can tick in the subtitle.
done
A ribbon scans left to right over 1.18s; at 36% the content is most out of focus (7.8px) and the badge, title and subtitle change there. The rim blooms, then settles to its resting glow over 1.4s.
log
View grows the pill downward over 420ms (rows 0fr to 1fr) while its corners ease from 36 to 26px; Hide folds it back.
failed
The badge crossfades to a red cross and the pill shakes once, ±5px over 380ms.
reduced motion
No ribbon, no shake: states change in place.

Usage

usage.tsx
import { StatusCapsule } from "@/components/status-capsule";<StatusCapsule  status={status}  title={status === "done" ? "Front door locked" : "Locking front door"}  subtitle="Deadbolt"  action={{ label: "Lock", onClick: lock }}/>

Depends on lucide-react, installed for you by the CLI along with the keyframes it needs.

Works with

A lock that reports back

Your request decides the status; the capsule only shows it. Pass the device’s history as the log.

example.tsx
"use client";import { useState } from "react";import { StatusCapsule, type CapsuleStatus } from "@/components/status-capsule";export function FrontDoor({ history }: { history: { id: string; label: string; time: string }[] }) {  const [status, setStatus] = useState<CapsuleStatus>("idle");  async function lock() {    setStatus("working");    const res = await fetch("/api/locks/front/lock", { method: "POST" });    setStatus(res.ok ? "done" : "failed");  }  return (    <StatusCapsule      status={status}      title={status === "done" ? "Front door locked" : status === "working" ? "Locking front door" : status === "failed" ? "Couldn’t lock" : "Front door"}      subtitle={status === "done" ? "Deadbolt · just now" : "Deadbolt"}      action={{ label: status === "failed" ? "Try again" : "Lock", onClick: lock }}      log={history}    />  );}

Props

status
"idle" | "working" | "done" | "failed"
What the task is doing. Done plays the ribbon and lights the rim.
title
string
The main line.
subtitle
string
The second line: a detail, a count, a time.
icon
ReactNode
The badge while idle or working; done and failed have their own.
action
{ label: string; icon?: ReactNode; onClick: () => void }
Idle: the button at the end. Failed: offered again. Done: at the foot of the log, or at the end when there’s no log.
log
{ id: string; label: string; detail?: string; time: string }[]
History, newest first, shown under View once done.
logLabel= "History"
string
Names the log for screen readers.
palette= "azure"
"azure" | "solar" | "prism" | "dusk" | LightPalette
The light’s colours.

Accessibility and motion

  • The light is a 2D canvas over the pill, drawn only while a ribbon crosses; the content under it is blurred on its own layer, so the pill’s edge stays crisp. Nothing runs while it’s still.
  • Words that change while it’s working show at once; only the change into done waits for the ribbon.
  • The badge’s icons crossfade with scale and blur; View’s label morphs; the log folds by height, never by fading in a separate panel.
  • On light surfaces the white of the light gives way to its colours, since white on white shows nothing.
  • A polite live region announces the title and subtitle when it’s done or failed; the ring and the light are hidden from screen readers.
  • Reduced motion drops the ribbon and the shake.

Requirements

React 19, Tailwind CSS v4 and shadcn/ui theme variables (any style, light and dark). Icons from lucide-react.

The CLI also installs Text morph.

Source

"use client";import * as React from "react";import { Check, X } from "lucide-react";import { LightSurface, useLightHeld, useLightReducedMotion, type LightPalette, type LightPaletteName, type LightSurfaceHandle } from "./light-surface";import { TextMorph } from "./text-morph";import { INTERACTION_FOCUS, INTERACTION_PRESS, interactionIcon } from "./ui-interaction-motion";/* ───────────────────────────────────────────────────────── * STATUS CAPSULE: a pill for something that takes a moment * *   working  a ring turns at the end of the pill while your *            task runs: locking, syncing, connecting *   done     a ribbon of light scans the pill from left to *            right; under it the badge becomes a check and the *            words change, and the pill keeps its light in the *            rim while it stays done *   log      View grows the same pill into the history below *            it, with your follow-up action at the foot *   failed   the badge turns red with a cross, the pill gives *            one shake and offers your action again * * Reduced motion: no ribbon and no shake; states change in place. * ───────────────────────────────────────────────────────── */export type CapsuleStatus = "idle" | "working" | "done" | "failed";export interface CapsuleLogEntry {  id: string;  label: string;  detail?: string;  time: string;}export interface CapsuleAction {  label: string;  icon?: React.ReactNode;  onClick: () => void;}export interface StatusCapsuleProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {  status: CapsuleStatus;  title: string;  subtitle?: string;  /** The badge while idle or working. A check and a cross are built in for done and failed. */  icon?: React.ReactNode;  /** Idle: the button at the end. Failed: shown again to retry. Done: at the foot of the log (or at the end if there's no log). */  action?: CapsuleAction;  /** What happened, newest first. Shown under View once done. */  log?: CapsuleLogEntry[];  /** Names the log for screen readers. */  logLabel?: string;  palette?: LightPaletteName | LightPalette;}function Dot() {  return (    <svg viewBox="0 0 20 20" className="size-[18px]" aria-hidden>      <circle cx="10" cy="10" r="4" fill="currentColor" />    </svg>  );}export function StatusCapsule({  status,  title,  subtitle,  icon,  action,  log,  logLabel = "History",  palette = "azure",  className = "",  ...props}: StatusCapsuleProps) {  const surface = React.useRef<LightSurfaceHandle>(null);  const reduced = useLightReducedMotion();  const logId = React.useId();  // Only a finish is worth the light; the words change under it.  const view = useLightHeld({ status, title, subtitle }, status, surface, () => (status === "done" ? { direction: "horizontal" } : null));  const [open, setOpen] = React.useState(false);  const hasLog = !!log?.length && view.status === "done";  const showLog = open && hasLog;  React.useEffect(() => {    if (view.status !== "failed" || reduced) return;    surface.current?.element()?.animate(      [{ transform: "none" }, { transform: "translateX(-5px)" }, { transform: "translateX(4px)" }, { transform: "translateX(-2px)" }, { transform: "none" }],      { duration: 380, easing: "ease-out" },    );  }, [view.status, reduced]);  const tone =    view.status === "done"      ? "bg-muted text-foreground"      : view.status === "failed"        ? "bg-red-500/12 text-red-600 dark:text-red-400"        : "bg-primary text-primary-foreground";  const trailing: "spinner" | "view" | "action" | null =    view.status === "working" ? "spinner" : hasLog ? "view" : action ? "action" : null;  const layer = (on: boolean): React.CSSProperties => ({ ...interactionIcon(on, reduced), gridArea: "1 / 1", pointerEvents: on ? "auto" : "none" });  return (    <LightSurface      ref={surface}      palette={palette}      direction="horizontal"      shape="capsule"      lit={view.status === "done"}           className={`w-full transition-[border-radius] duration-[420ms] ease-[cubic-bezier(0.16,1,0.3,1)] ${showLog ? "rounded-[26px]" : "rounded-[36px]"} ${className}`}      {...props}    >      <div className="px-3.5 py-3">        <div className="flex items-center gap-3">          <span className={`relative grid size-11 shrink-0 place-items-center rounded-full transition-colors duration-300 ${tone}`}>            <span className="grid place-items-center" style={layer(view.status === "idle" || view.status === "working")}>              {icon ?? <Dot />}            </span>            <span className="grid place-items-center" style={layer(view.status === "done")}>              <Check className="size-5" strokeWidth={2.4} aria-hidden />            </span>            <span className="grid place-items-center" style={layer(view.status === "failed")}>              <X className="size-5" strokeWidth={2.4} aria-hidden />            </span>          </span>          <div className="min-w-0 flex-1">            <div className="truncate text-[15.5px] font-medium tracking-[-0.015em] text-foreground">{view.title}</div>            {view.subtitle && <div className="truncate text-[13px] text-muted-foreground">{view.subtitle}</div>}          </div>          <div className="grid shrink-0 items-center justify-items-end">            <span aria-hidden className="grid size-10 place-items-center" style={layer(trailing === "spinner")}>              <span className="block size-5 animate-spin rounded-full border-2 border-foreground/15 border-t-foreground/75 [animation-duration:900ms]" />            </span>            <button              type="button"              tabIndex={trailing === "view" ? 0 : -1}              aria-hidden={trailing !== "view"}              aria-expanded={showLog}              aria-controls={logId}              onClick={() => setOpen((v) => !v)}              className={`h-9 cursor-pointer rounded-full bg-muted px-4 text-[13px] font-medium text-foreground hover:bg-accent ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}              style={layer(trailing === "view")}            >              <TextMorph>{showLog ? "Hide" : "View"}</TextMorph>            </button>            {action && (              <button                type="button"                tabIndex={trailing === "action" ? 0 : -1}                aria-hidden={trailing !== "action"}                onClick={action.onClick}                className={`inline-flex h-9 cursor-pointer items-center gap-1.5 rounded-full px-4 text-[13px] font-medium ${                  view.status === "idle" ? "bg-primary text-primary-foreground" : "bg-muted text-foreground hover:bg-accent"                } ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}                style={layer(trailing === "action")}              >                {action.icon}                {action.label}              </button>            )}          </div>        </div>        <div          id={logId}          role="region"          aria-label={logLabel}          inert={!showLog}          className="grid transition-[grid-template-rows,opacity] duration-[420ms] ease-[cubic-bezier(0.16,1,0.3,1)]"          style={{ gridTemplateRows: showLog ? "1fr" : "0fr", opacity: showLog ? 1 : 0 }}        >          <div className="min-h-0 min-w-0 overflow-clip">            <div className="mt-3 border-t border-border px-1 pt-3">              <ul className="space-y-2">                {(log ?? []).map((e) => (                  <li key={e.id} className="flex items-center justify-between gap-3 text-[13px]">                    <span className="min-w-0 truncate text-foreground">                      {e.label}                      {e.detail && (                        <>                          <span aria-hidden className="mx-1.5 text-muted-foreground/60">                            ·                          </span>                          <span className="text-muted-foreground">{e.detail}</span>                        </>                      )}                    </span>                    <span className="shrink-0 font-mono text-[12px] tabular-nums text-muted-foreground">{e.time}</span>                  </li>                ))}              </ul>              {action && (                <div className="mt-3 flex justify-end pb-0.5">                  <button                    type="button"                    onClick={() => {                      setOpen(false);                      action.onClick();                    }}                    className={`inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-full bg-muted px-3.5 text-[12.5px] font-medium text-foreground hover:bg-accent ${INTERACTION_PRESS} ${INTERACTION_FOCUS}`}                  >                    {action.icon}                    {action.label}                  </button>                </div>              )}            </div>          </div>        </div>      </div>      <span className="sr-only" aria-live="polite">        {view.status === "done" || view.status === "failed" ? `${view.title}${view.subtitle ? `, ${view.subtitle}` : ""}` : ""}      </span>    </LightSurface>  );}

Registry item: /r/status-capsule.json