# Status badge

Animated labels for pending, success and error states.

Access: free. Category: Feedback. Kind: primitive.

## When to use

- Use it when a product interface needs animated labels for pending, success and error states.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose alert instead when inline notices with icons, actions and optional dismissal is the actual interface need, rather than status badge.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Status badge

```sh
npx shadcn@latest add https://tidalui.com/r/status-badge.json
```

Stylesheets: `components/ui/tidal.css`, `components/ui/status-badge.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/status-badge.css";
import{TidalStatusBadge}from"./components/ui/status-badge";
export default()=><div className="tidal-scope"><TidalStatusBadge label="Ready"/></div>;
```

## Structured props

- `TidalStatusBadge.announce?: boolean | undefined` (default false): Opt into polite announcements for a changing status. Static collections should leave this false.
- `TidalStatusBadge.children?: string | undefined`: String-only alias for label. Rich children are intentionally rejected.
- `TidalStatusBadge.label?: string | undefined`: Visible status text. When both forms are supplied, label takes precedence.
- `TidalStatusBadge.size?: "sm" | "md" | undefined` (default "md"): Optional size value accepted by this exported component.
- `TidalStatusBadge.status?: TidalStatus | undefined` (default "neutral"): Optional status value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/status-badge.tsx) | [Manifest](https://tidalui.com/examples/status-badge.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useEffect, useLayoutEffect, useRef, useState } from "react";

import { Folder, Check, X } from "lucide-react";

import { TidalStatusBadge, type TidalStatus } from "./components/ui/status-badge";

import { TidalButton } from "./components/ui/tidal-button";

import "./components/ui/status-badge.css";



const tidalExampleStyles = ".status-badge-specimen{width:100%;max-width:600px;padding:28px;border:1px solid var(--t-border);border-radius:var(--t-radius-card);background:var(--t-surface);box-shadow:0 24px 40px -28px #00000035,0 2px 4px #00000008}.status-badge-specimen>h3{font-size:29px;line-height:1.08;letter-spacing:-1px;font-weight:500;margin:13px 0 26px}.status-badge-specimen>h3>em{font-family:\"Instrument Serif\",serif;font-size:1.2em;font-weight:400}.status-demo-top{display:flex;align-items:center;justify-content:space-between;gap:16px}.status-demo-top>span:first-child{display:flex;align-items:center;gap:11px;min-width:0}.status-demo-top strong{font-size:12px;font-weight:550;display:block}.status-demo-top small{display:block;color:var(--t-muted);font-size:11px;margin-top:6px}.status-demo-top>.tidal-status-badge{flex:none}.status-demo-progress{height:4px;border-radius:3px;background:var(--t-wash);margin:22px 0 11px;overflow:hidden}.status-demo-progress>span{display:block;height:100%;background:var(--t-ink);border-radius:3px;transition:width 600ms var(--t-ease-out)}.status-demo-checks>div{display:flex;align-items:center;gap:11px;min-height:62px;border-bottom:1px solid var(--t-border);color:var(--t-muted);font-size:11px;transition:color 240ms}.status-demo-checks>div[data-complete=true],.status-demo-checks>div[data-failed=true]{color:var(--t-ink)}.status-demo-checks>div>.tidal-status-badge{margin-left:auto;flex:none}.status-demo-step{width:24px;height:24px;border:1px solid var(--t-border);border-radius:6px;display:grid;place-items:center;font-size:11px;flex:none;transition:background 240ms,color 240ms,transform 320ms var(--t-ease-spring)}.status-demo-checks>div[data-complete=true]>.status-demo-step{background:var(--t-ink);border-color:var(--t-ink);color:var(--t-surface);transform:scale(1.04)}.status-demo-checks>div[data-failed=true]>.status-demo-step{border-color:var(--t-ink);color:var(--t-ink)}.status-demo-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:24px}.status-demo-actions>.tidal-button{font-size:11px;padding-inline:13px}.status-demo-note{font-size:11px;line-height:1.8;color:var(--t-muted);margin:18px 0 0;min-height:36px}.status-demo-legend{display:flex;align-items:center;gap:10px;border-top:1px solid var(--t-border);padding-top:18px;margin-top:14px}.status-demo-legend>span:last-child{font-size:11px;color:var(--t-muted)}@media(max-width:420px){.status-badge-specimen{padding:22px}.status-demo-top{align-items:flex-start;flex-direction:column;gap:14px}.status-demo-checks>div{font-size:11px;gap:8px}.status-demo-legend{flex-wrap:wrap}}";

export function StatusBadgeDemo() {
  const [phase, setPhase] = useState<
    "queued" | "checking" | "ready" | "failed"
  >("queued");
  const [step, setStep] = useState(0);
  const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
  const focusOwner = useRef<HTMLButtonElement | null>(null);
  const clear = () => {
    timers.current.forEach(clearTimeout);
    timers.current = [];
  };
  useEffect(() => () => timers.current.forEach(clearTimeout), []);
  const status: TidalStatus =
    phase === "checking"
      ? "pending"
      : phase === "ready"
        ? "success"
        : phase === "failed"
          ? "error"
          : "neutral";
  const label =
    phase === "checking"
      ? "Running checks"
      : phase === "ready"
        ? "Ready to preview"
        : phase === "failed"
          ? "Needs attention"
          : "Queued";
  const progress = Math.round((step / 3) * 100);
  useLayoutEffect(() => {
    if ((phase !== "ready" && phase !== "failed") || !focusOwner.current)
      return;
    const active = document.activeElement;
    if (active === document.body || active === focusOwner.current)
      focusOwner.current.focus({ preventScroll: true });
    focusOwner.current = null;
  }, [phase]);
  function run(fail: boolean, source: HTMLButtonElement) {
    clear();
    focusOwner.current = source;
    setStep(0);
    setPhase("checking");
    timers.current = [
      setTimeout(() => setStep(1), 400),
      setTimeout(() => setStep(2), 850),
      setTimeout(() => {
        setStep(fail ? 2 : 3);
        setPhase(fail ? "failed" : "ready");
      }, 1400),
    ];
  }
  return (
    <div className="status-badge-specimen" data-phase={phase}>
      <div className="status-demo-top">
        <span>
          <Folder size={16} aria-hidden="true" />
          <span>
            <strong>Northstar interface</strong>
            <small>Simulated check, in this browser only</small>
          </span>
        </span>
        <TidalStatusBadge status={status} label={label} announce />
      </div>
      <div
        className="status-demo-progress"
        role="progressbar"
        aria-label="Simulated check progress"
        aria-valuenow={progress}
        aria-valuemin={0}
        aria-valuemax={100}
      >
        <span style={{ width: `${progress}%` }} />
      </div>
      <div className="status-demo-checks">
        {["Component contract", "Styles and tokens", "Preview layout"].map(
          (name, i) => {
            const complete = i < step;
            const failed = phase === "failed" && i === 2;
            const pending = phase === "checking" && i === step;
            return (
              <div key={name} data-complete={complete} data-failed={failed}>
                <span className="status-demo-step" aria-hidden="true">
                  {complete ? (
                    <Check size={12} />
                  ) : failed ? (
                    <X size={12} />
                  ) : (
                    <span>0{i + 1}</span>
                  )}
                </span>
                <span>{name}</span>
                <TidalStatusBadge
                  label={
                    complete
                      ? "Sample passed"
                      : failed
                        ? "Sample failed"
                        : pending
                          ? "Checking"
                          : "Waiting"
                  }
                  status={
                    complete
                      ? "success"
                      : failed
                        ? "error"
                        : pending
                          ? "pending"
                          : "neutral"
                  }
                  size="sm"
                />
              </div>
            );
          },
        )}
      </div>
      <div className="status-demo-actions">
        <TidalButton
          onClick={(event) => run(false, event.currentTarget)}
          disabled={phase === "checking"}
        >
          Run sample check
        </TidalButton>
        <TidalButton
          variant="secondary"
          onClick={(event) => run(true, event.currentTarget)}
          disabled={phase === "checking"}
        >
          Try failure
        </TidalButton>
        <TidalButton
          variant="ghost"
          onClick={() => {
            clear();
            focusOwner.current = null;
            setStep(0);
            setPhase("queued");
          }}
        >
          Reset
        </TidalButton>
      </div>
      <p className="status-demo-note">
        {phase === "ready"
          ? "All three sample steps finished. Your real operation supplies the status."
          : phase === "failed"
            ? "The last sample step failed. Clear words make the next step obvious."
            : "Run a sample to see the label, icon and interface change together."}
      </p>
      <div className="status-demo-legend">
        <TidalStatusBadge label="Review requested" status="warning" size="sm" />
        <span>One palette. Every state understood.</span>
      </div>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <StatusBadgeDemo />
    </div>
  );
}

```

## Gotchas

- Use either label or string children for the visible status; label wins when both are supplied, and rich children are rejected.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Required short descriptive label:string. Optional status neutral|pending|success|warning|error (defaultneutral), size sm|md (defaultmd), announce (defaultfalse), native span attributes/ref, className/style. Label text defines the status; icons are decorative. Width follows intrinsic text/font changes; an explicit style.width opts out of automatic measurement. Constrained labels visually truncate while retaining their full accessible text. Pending spinner runs only while pending and stops with reduced motion. Opt into announce only for a changing status, not every badge in a static list. The caller owns actual state and operation lifecycle.
