# Status Pill

> A small pill that morphs between live states, such as recording, saving, and saved.

Source: https://www.honestui.com/docs/animated/status-pill

```tsx
"use client";

import { useEffect, useRef, useState } from "react";
import { StatusPill } from "@/registry/default/animated/status-pill";

type Phase = "idle" | "recording" | "saving" | "saved";

function formatTime(seconds: number) {
  return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
}

export function StatusPillDemo() {
  const [phase, setPhase] = useState<Phase>("idle");
  const [seconds, setSeconds] = useState(0);
  const saveTimer = useRef<number | undefined>(undefined);

  useEffect(() => {
    if (phase !== "recording") return;
    const id = window.setInterval(() => setSeconds((value) => value + 1), 1000);
    return () => window.clearInterval(id);
  }, [phase]);

  useEffect(() => () => window.clearTimeout(saveTimer.current), []);

  const stop = () => {
    setPhase("saving");
    saveTimer.current = window.setTimeout(() => setPhase("saved"), 1400);
  };

  const pill = {
    idle: <StatusPill status="idle" label="Ready to record" />,
    recording: <StatusPill status="recording" tone="recording" appearance="solid" label="Recording" detail={formatTime(seconds)} />,
    saving: <StatusPill status="saving" busy appearance="solid" label="Saving clip…" />,
    saved: <StatusPill status="saved" tone="success" label="Saved to library" />,
  }[phase];

  return (
    <div className="flex w-full max-w-lg flex-col items-center gap-8">
      <div className="flex flex-col items-center gap-4">
        <div className="flex h-10 items-center">{pill}</div>
        <div className="flex gap-2">
          <button
            type="button"
            className="h-8 rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted/60 disabled:opacity-50"
            disabled={phase === "recording" || phase === "saving"}
            onClick={() => {
              setSeconds(0);
              setPhase("recording");
            }}
          >
            {phase === "saved" ? "Record again" : "Record"}
          </button>
          <button
            type="button"
            className="h-8 rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted/60 disabled:opacity-50"
            disabled={phase !== "recording"}
            onClick={stop}
          >
            Stop
          </button>
        </div>
      </div>
      <div className="flex flex-wrap items-center justify-center gap-2 border-t border-border pt-6">
        <StatusPill size="sm" tone="info" live label="Syncing" announce={false} />
        <StatusPill size="sm" tone="success" label="Deployed" announce={false} />
        <StatusPill size="sm" tone="warning" label="2 checks pending" announce={false} />
        <StatusPill size="sm" tone="danger" label="Build failed" announce={false} />
      </div>
    </div>
  );
}

```

## Overview [#overview]

Status Pill shows one live status in a compact surface. When the status changes, the outgoing content blurs away, the new content blurs in, and the pill glides to its new width, so a sequence like Recording, Saving, and Saved reads as one object changing rather than three badges swapping.

Each state has a tone that sets its color and default icon. `recording` adds a pulsing red dot, `busy` shows a spinner, and `live` shows a pulsing dot in the tone's color. A `detail`, such as a timer, updates in place without replaying the transition.

## Installation [#installation]

<CliBlock commands="[&#x22;status-pill&#x22;]" />

## Usage [#usage]

```tsx
import { StatusPill } from "@/components/animated/status-pill"

<StatusPill
  status="recording"
  tone="recording"
  appearance="solid"
  label="Recording"
  detail={elapsed}
/>
```

Render a new state by changing `status` and the props that describe it:

```tsx
{saving ? (
  <StatusPill status="saving" busy label="Saving clip…" />
) : (
  <StatusPill status="saved" tone="success" label="Saved to library" />
)}
```

`status` identifies the state and defaults to the label when the label is plain text. Changing only `detail` keeps the same state.

## Accessibility [#accessibility]

Each new label is announced once through a polite live region. Timer ticks and other `detail` changes are not announced, so a running clock does not interrupt the reader; the current detail is still read when someone reaches the pill. Pass `announcement` when the label is not plain text, and `announce={false}` for a static pill that never changes.

Color is never the only signal: every tone carries a label, and the success, warning, and danger tones add an icon. With reduced motion enabled, the content changes with a short fade, the width changes instantly, and the pulsing dot and spinner hold still.

## API Reference [#api-reference]


  ### `label`

type: `ReactNode`

What is happening, such as "Recording" or "Saved".

  ### `status`

type: `string`

Identifies the state. A change morphs the content and announces the label. Defaults to the label when it is text.

  ### `detail`

type: `ReactNode`

Secondary text after the label, such as a timer. Updates in place and is not announced.

  ### `tone`

type: `&#x22;neutral&#x22; | &#x22;info&#x22; | &#x22;success&#x22; | &#x22;warning&#x22; | &#x22;danger&#x22; | &#x22;recording&#x22;` · default: `&#x22;neutral&#x22;`

Color and default icon.

  ### `appearance`

type: `&#x22;soft&#x22; | &#x22;solid&#x22;` · default: `&#x22;soft&#x22;`

Tinted or filled surface.

  ### `icon`

type: `ReactNode`

Leading icon. Overrides the tone's default; 

    `null`

     removes it.

  ### `busy`

type: `boolean` · default: `false`

Shows a spinner in place of the icon.

  ### `live`

type: `boolean`

Shows a pulsing dot in place of the icon. On by default for 

    `recording`

    .

  ### `size`

type: `&#x22;sm&#x22; | &#x22;md&#x22;` · default: `&#x22;md&#x22;`

Pill height and text size.

  ### `announce`

type: `boolean` · default: `true`

Announces label changes through a polite live region.

  ### `announcement`

type: `string`

Text announced for this state when the label is not plain text.

  ### `className`

type: `string`

Class for the pill surface.
