# Status Pill

A tinted pill with a dot for a status, such as Active or Failed.

Tinted pill with a leading status dot: relationship status, run state, health. One line, never wraps or shrinks. Sizes md (24px) and sm (22px); a mark (circle with a check) for a finished state. The squarer, bordered label of tables and fields is the Tag.

Kind: component · Category: Display · Status: stable · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add status-pill
```

It writes the folder `status-pill/` into the project's ui folder (`index.ts`, `status-pill.tsx`, `StatusPill.vue`, `StatusPill.svelte`, `status-pill.recipe.ts`). First time: [Installation](/installation.md).

## Usage

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

```vue
import { StatusPill } from "@/components/ui/status-pill";
```

```svelte
import { StatusPill } from "$lib/components/ui/status-pill";
```

## Parts

In the DOM the root carries `data-slot="status-pill"` and each part `data-slot="status-pill-<part>"`; in the recipe the root is the `base` slot and each part a slot named after it in camelCase.

| Part | Element | data-slot | Flags | Notes |
| --- | --- | --- | --- | --- |
| `root` | `span` | `status-pill` |  |  |
| `dot` | `span` | `status-pill-dot` | optional | 6px dot in the tone's colour; aria-hidden. |
| `mark` | `span` | `status-pill-mark` | optional | 18px circle (16px at sm) with a check, in the tone's colour; replaces the dot for a finished state ("Sent", "Applied"). aria-hidden; it pops in (motion.popup-scale) only when it appears after the pill has been painted. |
| `label` | `span` | `status-pill-label` | optional | Text of the status; truncates at the end when the pill has less room than its text. Pass title with the full text when it can truncate. |
| `trailing` | `span` | `status-pill-trailing` | optional | A glyph after the label (12px, 11px at sm), aria-hidden (a failed task's retry arrow). |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `tone` | `"neutral" \| "accent" \| "green" \| "orange" \| "red" \| "blue"` | `"neutral"` | neutral (inset fill, ink-2 text), the four status tones with their tint pairs (accent: accent-tint and accent-ink; green, orange, red), and blue, whose fill and text mix from color.tag-blue (a beta badge, for instance). |
| `size` | `"md" \| "sm"` | `"md"` | md 24px / 13px; sm 22px / 11.5px. |
| `dot` | `boolean` | `true` | Render the leading dot part. |
| `mark` | `boolean` | `false` | Render the mark (circle with a check) in place of the dot; it pops in when it appears after the first paint (a status change). |
| `dotTone` | `"accent" \| "green" \| "orange" \| "red" \| "blue" \| "purple" \| "cyan" \| "yellow" \| "pink"` |  | A neutral pill whose dot alone takes this colour: the status tones or one of the tag hues (a diff-table category). Set only when given. |

Other attributes and `class` go to the root; `class` is merged through the recipe.

## Slots

| Slot | Content |
| --- | --- |
| `default` | Label |
| `trailingIcon` | A glyph after the label (React: trailingIcon node; Vue: #trailing slot; Svelte: trailingIcon snippet). |

## Keyboard and accessibility

Notes:

- The dot and the mark are aria-hidden; the label carries the state. Tone alone never does.
- When the status changes while the user waits, put the pill in a role="status" region.

## Motion

- the mark pops in when it appears after the pill has been painted (a status change): opacity and scale from motion.popup-scale, duration.popup, easing.out-strong, from @starting-style; data-enter marks a painted pill (lib/paint.ts), so nothing plays on first paint and setting data-enter starts nothing; reduced motion: fade only
- no other motion

## Tokens

`color.inset`, `color.surface`, `color.ink`, `color.ink-2`, `color.ink-3`, `color.on-accent`, `color.accent`, `color.accent-tint`, `color.accent-ink`, `color.green`, `color.green-tint`, `color.orange`, `color.orange-tint`, `color.red`, `color.red-tint`, `color.tag-blue`, `color.tag-green`, `color.tag-orange`, `color.tag-red`, `color.tag-purple`, `color.tag-cyan`, `color.tag-yellow`, `color.tag-pink`, `radius.pill`, `text.sm`, `duration.popup`, `motion.popup-scale`, `easing.out-strong`

## Examples

### Recent deploys

React · `recent-deploys.tsx`

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

const deploys = [
  { id: "dpl_7f3a9c", project: "web-app", when: "2 min ago", status: "Ready", tone: "green" },
  { id: "dpl_2c81e0", project: "billing-api", when: "Just now", status: "Building", tone: "orange" },
  { id: "dpl_9b04d7", project: "docs-site", when: "1 h ago", status: "Failed", tone: "red" },
] as const;

export default function RecentDeploys() {
  return (
    <ul className="flex w-80 flex-col divide-y divide-line text-sm">
      {deploys.map((deploy) => (
        <li key={deploy.id} className="flex items-center gap-3 py-2">
          <span className="font-medium text-ink">{deploy.project}</span>
          <span className="flex-1 text-ink-2">{deploy.when}</span>
          <StatusPill tone={deploy.tone}>{deploy.status}</StatusPill>
        </li>
      ))}
    </ul>
  );
}
```

Vue · `recent-deploys.vue`

```vue
<script setup lang="ts">
import { StatusPill } from "@/components/ui/status-pill";

const deploys = [
  { id: "dpl_7f3a9c", project: "web-app", when: "2 min ago", status: "Ready", tone: "green" },
  { id: "dpl_2c81e0", project: "billing-api", when: "Just now", status: "Building", tone: "orange" },
  { id: "dpl_9b04d7", project: "docs-site", when: "1 h ago", status: "Failed", tone: "red" },
] as const;
</script>

<template>
  <ul class="flex w-80 flex-col divide-y divide-line text-sm">
    <li v-for="deploy in deploys" :key="deploy.id" class="flex items-center gap-3 py-2">
      <span class="font-medium text-ink">{{ deploy.project }}</span>
      <span class="flex-1 text-ink-2">{{ deploy.when }}</span>
      <StatusPill :tone="deploy.tone">{{ deploy.status }}</StatusPill>
    </li>
  </ul>
</template>
```

Svelte · `recent-deploys.svelte`

```svelte
<script lang="ts">
  import { StatusPill } from "$lib/components/ui/status-pill";

  const deploys = [
    { id: "dpl_7f3a9c", project: "web-app", when: "2 min ago", status: "Ready", tone: "green" },
    { id: "dpl_2c81e0", project: "billing-api", when: "Just now", status: "Building", tone: "orange" },
    { id: "dpl_9b04d7", project: "docs-site", when: "1 h ago", status: "Failed", tone: "red" },
  ] as const;
</script>

<ul class="flex w-80 flex-col divide-y divide-line text-sm">
  {#each deploys as deploy (deploy.id)}
    <li class="flex items-center gap-3 py-2">
      <span class="font-medium text-ink">{deploy.project}</span>
      <span class="flex-1 text-ink-2">{deploy.when}</span>
      <StatusPill tone={deploy.tone}>{deploy.status}</StatusPill>
    </li>
  {/each}
</ul>
```

### Status column of an invoices table

React · `invoices-table.tsx`

```tsx
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const invoices = [
  { id: "INV-2024-0123", amount: "$1,240.00", status: "Due", tone: "orange" },
  { id: "INV-2024-0117", amount: "$1,240.00", status: "Paid", tone: "green" },
  { id: "INV-2024-0109", amount: "$980.00", status: "Payment failed", tone: "red" },
] as const;

/* sm pills keep the rows of a dense table at their height */
export default function InvoicesTable() {
  return (
    <Table aria-label="Invoices" className="w-[380px] max-w-full">
      <TableHeader>
        <TableRow>
          <TableHead>Invoice</TableHead>
          <TableHead numeric>Amount</TableHead>
          <TableHead>Status</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {invoices.map((invoice) => (
          <TableRow key={invoice.id}>
            <TableCell>{invoice.id}</TableCell>
            <TableCell numeric>{invoice.amount}</TableCell>
            <TableCell><StatusPill tone={invoice.tone} size="sm">{invoice.status}</StatusPill></TableCell>
          </TableRow>
        ))}
      </TableBody>
    </Table>
  );
}
```

Vue · `invoices-table.vue`

```vue
<script setup lang="ts">
import { StatusPill } from "@/components/ui/status-pill";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

const invoices = [
  { id: "INV-2024-0123", amount: "$1,240.00", status: "Due", tone: "orange" },
  { id: "INV-2024-0117", amount: "$1,240.00", status: "Paid", tone: "green" },
  { id: "INV-2024-0109", amount: "$980.00", status: "Payment failed", tone: "red" },
] as const;
</script>

<!-- sm pills keep the rows of a dense table at their height -->
<template>
  <Table aria-label="Invoices" class="w-[380px] max-w-full">
    <TableHeader>
      <TableRow>
        <TableHead>Invoice</TableHead>
        <TableHead numeric>Amount</TableHead>
        <TableHead>Status</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow v-for="invoice in invoices" :key="invoice.id">
        <TableCell>{{ invoice.id }}</TableCell>
        <TableCell numeric>{{ invoice.amount }}</TableCell>
        <TableCell><StatusPill :tone="invoice.tone" size="sm">{{ invoice.status }}</StatusPill></TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
```

Svelte · `invoices-table.svelte`

```svelte
<script lang="ts">
  import { StatusPill } from "$lib/components/ui/status-pill";
  import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "$lib/components/ui/table";

  const invoices = [
    { id: "INV-2024-0123", amount: "$1,240.00", status: "Due", tone: "orange" },
    { id: "INV-2024-0117", amount: "$1,240.00", status: "Paid", tone: "green" },
    { id: "INV-2024-0109", amount: "$980.00", status: "Payment failed", tone: "red" },
  ] as const;
</script>

<!-- sm pills keep the rows of a dense table at their height -->
<Table aria-label="Invoices" class="w-[380px] max-w-full">
  <TableHeader>
    <TableRow>
      <TableHead>Invoice</TableHead>
      <TableHead numeric>Amount</TableHead>
      <TableHead>Status</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    {#each invoices as invoice (invoice.id)}
      <TableRow>
        <TableCell>{invoice.id}</TableCell>
        <TableCell numeric>{invoice.amount}</TableCell>
        <TableCell><StatusPill tone={invoice.tone} size="sm">{invoice.status}</StatusPill></TableCell>
      </TableRow>
    {/each}
  </TableBody>
</Table>
```

### Pull request approved

React · `review-approved.tsx`

```tsx
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { StatusPill } from "@/components/ui/status-pill";

/* the mark replaces the dot for a finished state and pops in when the status changes */
export default function ReviewApproved() {
  const [approved, setApproved] = useState(false);
  return (
    <div className="flex w-80 flex-col gap-3 text-sm">
      <div className="flex items-start gap-3">
        <div className="min-w-0 flex-1">
          <p className="font-medium text-ink">Add retry to webhook delivery</p>
          <p className="text-ink-2">#482 · feat/webhook-retry into main</p>
        </div>
        {approved ? (
          <StatusPill tone="green" mark>Approved</StatusPill>
        ) : (
          <StatusPill tone="neutral">In review</StatusPill>
        )}
      </div>
      <div className="flex gap-2">
        <Button size="sm" variant="primary" disabled={approved} onClick={() => setApproved(true)}>Approve</Button>
        <Button size="sm" variant="ghost" onClick={() => setApproved(false)}>Request changes</Button>
      </div>
    </div>
  );
}
```

Vue · `review-approved.vue`

```vue
<script setup lang="ts">
import { ref } from "vue";
import { Button } from "@/components/ui/button";
import { StatusPill } from "@/components/ui/status-pill";

const approved = ref(false);
</script>

<!-- the mark replaces the dot for a finished state and pops in when the status changes -->
<template>
  <div class="flex w-80 flex-col gap-3 text-sm">
    <div class="flex items-start gap-3">
      <div class="min-w-0 flex-1">
        <p class="font-medium text-ink">Add retry to webhook delivery</p>
        <p class="text-ink-2">#482 · feat/webhook-retry into main</p>
      </div>
      <StatusPill v-if="approved" tone="green" mark>Approved</StatusPill>
      <StatusPill v-else tone="neutral">In review</StatusPill>
    </div>
    <div class="flex gap-2">
      <Button size="sm" variant="primary" :disabled="approved" @click="approved = true">Approve</Button>
      <Button size="sm" variant="ghost" @click="approved = false">Request changes</Button>
    </div>
  </div>
</template>
```

Svelte · `review-approved.svelte`

```svelte
<script lang="ts">
  import { Button } from "$lib/components/ui/button";
  import { StatusPill } from "$lib/components/ui/status-pill";

  let approved = $state(false);
</script>

<!-- the mark replaces the dot for a finished state and pops in when the status changes -->
<div class="flex w-80 flex-col gap-3 text-sm">
  <div class="flex items-start gap-3">
    <div class="min-w-0 flex-1">
      <p class="font-medium text-ink">Add retry to webhook delivery</p>
      <p class="text-ink-2">#482 · feat/webhook-retry into main</p>
    </div>
    {#if approved}
      <StatusPill tone="green" mark>Approved</StatusPill>
    {:else}
      <StatusPill tone="neutral">In review</StatusPill>
    {/if}
  </div>
  <div class="flex gap-2">
    <Button size="sm" variant="primary" disabled={approved} onclick={() => (approved = true)}>Approve</Button>
    <Button size="sm" variant="ghost" onclick={() => (approved = false)}>Request changes</Button>
  </div>
</div>
```

### Environments

React · `environments.tsx`

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

/* a neutral pill whose dot alone carries the colour: a category, not a state */
const environments = [
  { name: "Production", dot: "green" },
  { name: "Staging", dot: "yellow" },
  { name: "Preview", dot: "purple" },
] as const;

export default function Environments() {
  return (
    <div className="flex flex-wrap gap-2">
      {environments.map((env) => (
        <StatusPill key={env.name} tone="neutral" dotTone={env.dot}>{env.name}</StatusPill>
      ))}
    </div>
  );
}
```

Vue · `environments.vue`

```vue
<script setup lang="ts">
import { StatusPill } from "@/components/ui/status-pill";

/* a neutral pill whose dot alone carries the colour: a category, not a state */
const environments = [
  { name: "Production", dot: "green" },
  { name: "Staging", dot: "yellow" },
  { name: "Preview", dot: "purple" },
] as const;
</script>

<template>
  <div class="flex flex-wrap gap-2">
    <StatusPill v-for="env in environments" :key="env.name" tone="neutral" :dotTone="env.dot">{{ env.name }}</StatusPill>
  </div>
</template>
```

Svelte · `environments.svelte`

```svelte
<script lang="ts">
  import { StatusPill } from "$lib/components/ui/status-pill";

  /* a neutral pill whose dot alone carries the colour: a category, not a state */
  const environments = [
    { name: "Production", dot: "green" },
    { name: "Staging", dot: "yellow" },
    { name: "Preview", dot: "purple" },
  ] as const;
</script>

<div class="flex flex-wrap gap-2">
  {#each environments as env (env.name)}
    <StatusPill tone="neutral" dotTone={env.dot}>{env.name}</StatusPill>
  {/each}
</div>
```

### Beta label on a setting

React · `beta-setting.tsx`

```tsx
import { StatusPill } from "@/components/ui/status-pill";
import { Switch } from "@/components/ui/switch";

export default function BetaSetting() {
  return (
    <div className="flex w-80 items-start gap-3 text-sm">
      <div className="min-w-0 flex-1">
        <p className="flex items-center gap-2 font-medium text-ink">
          Usage alerts <StatusPill tone="blue" size="sm" dot={false}>Beta</StatusPill>
        </p>
        <p className="text-ink-2">Email the owners when a project passes 80% of its build minutes.</p>
      </div>
      <Switch label="Usage alerts" />
    </div>
  );
}
```

Vue · `beta-setting.vue`

```vue
<script setup lang="ts">
import { StatusPill } from "@/components/ui/status-pill";
import { Switch } from "@/components/ui/switch";
</script>

<template>
  <div class="flex w-80 items-start gap-3 text-sm">
    <div class="min-w-0 flex-1">
      <p class="flex items-center gap-2 font-medium text-ink">
        Usage alerts <StatusPill tone="blue" size="sm" :dot="false">Beta</StatusPill>
      </p>
      <p class="text-ink-2">Email the owners when a project passes 80% of its build minutes.</p>
    </div>
    <Switch label="Usage alerts" />
  </div>
</template>
```

Svelte · `beta-setting.svelte`

```svelte
<script lang="ts">
  import { StatusPill } from "$lib/components/ui/status-pill";
  import { Switch } from "$lib/components/ui/switch";
</script>

<div class="flex w-80 items-start gap-3 text-sm">
  <div class="min-w-0 flex-1">
    <p class="flex items-center gap-2 font-medium text-ink">
      Usage alerts <StatusPill tone="blue" size="sm" dot={false}>Beta</StatusPill>
    </p>
    <p class="text-ink-2">Email the owners when a project passes 80% of its build minutes.</p>
  </div>
  <Switch label="Usage alerts" />
</div>
```

## Recipe

`status-pill.recipe.ts`:

```ts
import { tv, type VariantProps } from "../lib/tv";

/* status-pill — tinted pill with a leading status dot. Never wraps, never shrinks.
 * Sizes: md 24px (default) · sm 22px. (The squarer, bordered label of tables and fields is the
 * Tag, its own component.) A mark (18px circle with a check) replaces the dot for a finished
 * state; it pops in when a painted pill turns finished (data-enter arrives after the first paint, lib/paint.ts, and
 * @starting-style only applies to an element that has just appeared), never on first paint.
 * A trailing icon part may stand after the label.
 *
 * Every tone sets --_hue; the mark takes its colour from it, and blue (a status with no tint pair
 * of its own, such as "beta") mixes its fill and text from it.
 * Variant order matters: dotTone < tone < size < mark (a later key wins). */

const MIXED = "bg-[color:color-mix(in_srgb,var(--_hue)_14%,var(--fndn-surface))] text-[color:color-mix(in_oklch,var(--_hue)_62%,var(--fndn-ink))]";

export const statusPill = tv({
  slots: {
    base: [
      "[--_hue:var(--fndn-ink-3)]",
      "inline-flex shrink-0 items-center gap-1.5 max-w-full h-6 px-2.5 rounded-pill",
      "text-sm font-medium leading-none whitespace-nowrap bg-inset text-ink-2",
    ],
    /* a status longer than the room truncates at the end of its own text; the 2px block padding,
     * taken back by the margin, keeps descenders out of the clip */
    label: "min-w-0 -my-0.5 py-0.5 overflow-hidden text-ellipsis [unicode-bidi:plaintext]",
    dot: "shrink-0 size-1.5 rounded-[50%] bg-ink-3",
    trailing: "inline-flex shrink-0 text-[12px] [&>[data-slot=icon]]:size-[1em] [&>svg]:size-[1em]",
    mark: [
      "inline-flex shrink-0 size-[18px] items-center justify-center rounded-[50%]",
      "bg-[color:var(--_hue)] text-on-accent",
      "[&>[data-slot=icon]]:size-[11px] [&>[data-slot=icon]]:text-[11px] [&>svg]:size-[11px] [&>svg]:text-[11px]",
      /* the pop-in, only inside a painted pill; reduced motion: popup-scale is 1, so it only fades */
      "[[data-slot=status-pill][data-enter]>&]:motion-opacity-popup [[data-slot=status-pill][data-enter]>&]:motion-transform-popup",
      "[[data-slot=status-pill][data-enter]>&]:starting:opacity-0 [[data-slot=status-pill][data-enter]>&]:starting:scale-popup",
    ],
  },
  variants: {
    /* a neutral pill whose dot alone carries a colour (a category) */
    dotTone: {
      accent: { dot: "bg-accent" },
      green: { dot: "bg-green" },
      orange: { dot: "bg-orange" },
      red: { dot: "bg-red" },
      blue: { dot: "bg-tag-blue" },
      purple: { dot: "bg-tag-purple" },
      cyan: { dot: "bg-tag-cyan" },
      yellow: { dot: "bg-tag-yellow" },
      pink: { dot: "bg-tag-pink" },
    },
    /* the four status tones keep their tint pair; blue mixes from its tag hue */
    tone: {
      neutral: {},
      accent: { base: "[--_hue:var(--fndn-accent)] bg-accent-tint text-accent-ink", dot: "bg-accent" },
      green: { base: "[--_hue:var(--fndn-tag-green)] bg-green-tint text-green", dot: "bg-green" },
      orange: { base: "[--_hue:var(--fndn-tag-orange)] bg-orange-tint text-orange", dot: "bg-orange" },
      red: { base: "[--_hue:var(--fndn-tag-red)] bg-red-tint text-red", dot: "bg-red" },
      blue: { base: ["[--_hue:var(--fndn-tag-blue)]", MIXED], dot: "bg-[color:var(--_hue)]" },
    },
    /* sm — 22px, for table cells and dense rows */
    size: {
      md: {},
      sm: {
        base: "h-[22px] px-2 text-[11.5px]",
        trailing: "text-[11px]",
        mark: "size-4 [&>[data-slot=icon]]:size-2.5 [&>[data-slot=icon]]:text-[10px] [&>svg]:size-2.5 [&>svg]:text-[10px]",
      },
    },
    mark: { true: { base: "ps-[3px]" } },
  },
  defaultVariants: { tone: "neutral", size: "md" },
});

export type StatusPillRecipeProps = VariantProps<typeof statusPill>;
```
