# Empty State

What a list, a table or a popup shows when there is nothing in it.

What a list, a table or a popup shows when there is nothing in it: an optional icon, a title, an optional hint and an optional action (the real Button the host passes: "New issue", "Clear filters"). A row sits in a list like one of its rows; a block is a centred stack for a popup or a table body. It fades in when it appears.

Kind: component · Category: Feedback · Status: beta · Targets: React, Vue, Svelte

## Add

```bash
npx fndn add empty-state
```

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

## Usage

```tsx
import { EmptyState } from "@/components/ui/empty-state";
```

```vue
import { EmptyState } from "@/components/ui/empty-state";
```

```svelte
import { EmptyState } from "$lib/components/ui/empty-state";
```

## Parts

In the DOM the root carries `data-slot="empty-state"` and each part `data-slot="empty-state-<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` | `div` | `empty-state` |  | data-size, data-align. The host toggles it with `hidden`. Extra attributes (hidden, id, role, aria-*) land on it in every target, so a host toggles it with hidden. |
| `icon` | `span` | `empty-state-icon` | optional | aria-hidden. Row: 14px ink-3 glyph. Block: a 32px tile in the hover grey with a soft hairline (line-soft) and a 15px glyph: quiet in both themes (in dark mode an inset tile read as a hole with a bright ring). |
| `title` | `p` | `empty-state-title` |  | The message |
| `hint` | `p` | `empty-state-hint` | optional | The next step |
| `action` | `div` | `empty-state-action` | optional | What to do next, passed by the host (React: action, a node; Vue: slot action; Svelte: snippet action), usually one Button (sm). Block: centred under the text, 14px below it. Row: at the end of the line. |

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` | `node (children / slot)` |  | The message. |
| `hint` | `string` |  | Optional next step. |
| `icon` | `string` |  | A name from the icon vocabulary (spec/icons.json), one of magnifying-glass, funnel, chats, folder-open, table, file, bell, check-circle, users, rocket-launch, list-checks, git-branch (the adapters type the prop to these names); or your own icon (React element, Vue slot `icon`, Svelte snippet). Any other string draws nothing: a name is never rendered as text. |
| `size` | `"row" \| "block"` | `"row"` | row: one line as tall as the list's rows (--option-height, 30px by default), 12px ink-2. block: a centred stack, 13px/500 ink title, 12px ink-2 hint, padding 32/16. |
| `align` | `"start" \| "center"` | `"start"` | Rows only: start the line with the list's text, or centre it (a message in a card or under a filter). A block is always centred. |
| `action` | `node (children / slot)` |  | What to do next: a Button (or two). React: a node; Vue: the action slot; Svelte: a snippet. |

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

## Slots

| Slot | Content |
| --- | --- |
| `icon` | Vue: your own icon in place of the named ones (React: icon as a node; Svelte: icon as a snippet). |
| `action` | Vue: what to do next (a Button), under a block's text or at the end of a row (React: action as a node; Svelte: action as a snippet). |

## States

`appearing`

## Keyboard and accessibility

Role: none (plain text).

Keyboard:

- Not focusable; nothing to operate

Notes:

- The icon is decorative (aria-hidden); the title says what is empty.
- When the empty state replaces results the user is typing for, announce it from the host's own status region (search and prompt-bar already have one); the empty state does not carry role=status, so it is never announced twice.
- Inside a listbox, keep it outside the options (it is not an option).
- The action is an ordinary Button in the tab order; its label says what it does ("New issue", not "Get started").

## Motion

- enter: opacity 0 -> 1 over duration.base ease when it appears, also out of `hidden` (@starting-style)
- exit: none; it goes when results arrive

## Tokens

`color.ink`, `color.ink-2`, `color.ink-3`, `radius.control`, `text.xs`, `text.sm`, `duration.base`, `color.hover`, `color.line-soft`

## Notes

- Replaces the hand-made empty states in search, prompt-bar, filter-table, records-table, insight-cards and sidebar-nav: the host keeps its spacing through its own class (a table cell's height, a card's inset background).

## Examples

### No deploys yet

React · `no-deploys.tsx`

```tsx
import { EmptyState } from "@/components/ui/empty-state";

export default function NoDeploys() {
  return (
    <EmptyState
      size="block"
      icon="folder-open"
      title="No deploys yet"
      hint="Push to main to create the first one."
      className="w-full"
    />
  );
}
```

Vue · `no-deploys.vue`

```vue
<script setup lang="ts">
import { EmptyState } from "@/components/ui/empty-state";
</script>

<template>
  <EmptyState
    size="block"
    icon="folder-open"
    title="No deploys yet"
    hint="Push to main to create the first one."
    class="w-full"
  />
</template>
```

Svelte · `no-deploys.svelte`

```svelte
<script lang="ts">
  import { EmptyState } from "$lib/components/ui/empty-state";
</script>

<EmptyState
  size="block"
  icon="folder-open"
  title="No deploys yet"
  hint="Push to main to create the first one."
  class="w-full"
/>
```

### An empty project, with the next step

React · `no-issues.tsx`

```tsx
import { Plus } from "@phosphor-icons/react";
import { Button } from "@/components/ui/button";
import { EmptyState } from "@/components/ui/empty-state";

/* the next step under the text: the one thing to do in an empty project */
export default function NoIssues() {
  return (
    <EmptyState
      size="block"
      icon="folder-open"
      title="No open issues in billing-api"
      hint="Issues you create or import show up here."
      action={<Button variant="outline" size="sm" shape="rounded" icon={<Plus data-slot="icon" weight="bold" />}>New issue</Button>}
    />
  );
}
```

Vue · `no-issues.vue`

```vue
<script setup lang="ts">
import { PhPlus } from "@phosphor-icons/vue";
import { Button } from "@/components/ui/button";
import { EmptyState } from "@/components/ui/empty-state";
</script>

<!-- the next step under the text: the one thing to do in an empty project -->
<template>
  <EmptyState size="block" icon="folder-open" title="No open issues in billing-api" hint="Issues you create or import show up here.">
    <template #action>
      <Button variant="outline" size="sm" shape="rounded">
        <template #icon><PhPlus data-slot="icon" weight="bold" /></template>
        New issue
      </Button>
    </template>
  </EmptyState>
</template>
```

Svelte · `no-issues.svelte`

```svelte
<script lang="ts">
  import Plus from "phosphor-svelte/lib/PlusIcon";
  import { Button } from "$lib/components/ui/button";
  import { EmptyState } from "$lib/components/ui/empty-state";
</script>

<!-- the next step under the text: the one thing to do in an empty project -->
<EmptyState size="block" icon="folder-open" title="No open issues in billing-api" hint="Issues you create or import show up here.">
  {#snippet action()}
    <Button variant="outline" size="sm" shape="rounded">
      {#snippet icon()}<Plus data-slot="icon" weight="bold" />{/snippet}
      New issue
    </Button>
  {/snippet}
</EmptyState>
```

### Search finds nothing

React · `search-no-results.tsx`

```tsx
import { Card } from "@/components/ui/card";
import { EmptyState } from "@/components/ui/empty-state";

/* the search palette when nothing matches the query */
export default function SearchNoResults() {
  return (
    <Card elevation="overlay" className="w-[300px] max-w-full">
      <EmptyState size="block" icon="magnifying-glass" title="No results for “billing-apy”" hint="Check the spelling, or search by project, person or deploy ID." />
    </Card>
  );
}
```

Vue · `search-no-results.vue`

```vue
<script setup lang="ts">
import { Card } from "@/components/ui/card";
import { EmptyState } from "@/components/ui/empty-state";
</script>

<!-- the search palette when nothing matches the query -->
<template>
  <Card elevation="overlay" class="w-[300px] max-w-full">
    <EmptyState size="block" icon="magnifying-glass" title="No results for “billing-apy”" hint="Check the spelling, or search by project, person or deploy ID." />
  </Card>
</template>
```

Svelte · `search-no-results.svelte`

```svelte
<script lang="ts">
  import { Card } from "$lib/components/ui/card";
  import { EmptyState } from "$lib/components/ui/empty-state";
</script>

<!-- the search palette when nothing matches the query -->
<Card elevation="overlay" class="w-[300px] max-w-full">
  <EmptyState size="block" icon="magnifying-glass" title="No results for “billing-apy”" hint="Check the spelling, or search by project, person or deploy ID." />
</Card>
```

### A filter matches nothing

React · `filter-no-matches.tsx`

```tsx
import { EmptyState } from "@/components/ui/empty-state";

/* under a filter bar: the pull request list is empty for these filters */
export default function FilterNoMatches() {
  return <EmptyState size="row" align="center" icon="funnel" title="No open pull requests by Lucas Moreau" className="w-80 max-w-full" />;
}
```

Vue · `filter-no-matches.vue`

```vue
<script setup lang="ts">
import { EmptyState } from "@/components/ui/empty-state";
</script>

<!-- under a filter bar: the pull request list is empty for these filters -->
<template>
  <EmptyState size="row" align="center" icon="funnel" title="No open pull requests by Lucas Moreau" class="w-80 max-w-full" />
</template>
```

Svelte · `filter-no-matches.svelte`

```svelte
<script lang="ts">
  import { EmptyState } from "$lib/components/ui/empty-state";
</script>

<!-- under a filter bar: the pull request list is empty for these filters -->
<EmptyState size="row" align="center" icon="funnel" title="No open pull requests by Lucas Moreau" class="w-80 max-w-full" />
```

### Nothing left in a picker

React · `member-picker.tsx`

```tsx
import { Card } from "@/components/ui/card";
import { EmptyState } from "@/components/ui/empty-state";

/* a member picker's list after typing "jonas.w": one row, at the list's row height */
export default function MemberPicker() {
  return (
    <Card elevation="overlay" className="w-80 max-w-full p-1">
      <EmptyState title="No members match “jonas.w”" hint="Invite by email instead" />
    </Card>
  );
}
```

Vue · `member-picker.vue`

```vue
<script setup lang="ts">
import { Card } from "@/components/ui/card";
import { EmptyState } from "@/components/ui/empty-state";
</script>

<!-- a member picker's list after typing "jonas.w": one row, at the list's row height -->
<template>
  <Card elevation="overlay" class="w-80 max-w-full p-1">
    <EmptyState title="No members match “jonas.w”" hint="Invite by email instead" />
  </Card>
</template>
```

Svelte · `member-picker.svelte`

```svelte
<script lang="ts">
  import { Card } from "$lib/components/ui/card";
  import { EmptyState } from "$lib/components/ui/empty-state";
</script>

<!-- a member picker's list after typing "jonas.w": one row, at the list's row height -->
<Card elevation="overlay" class="w-80 max-w-full p-1">
  <EmptyState title="No members match “jonas.w”" hint="Invite by email instead" />
</Card>
```

### No invoices yet, in a table

React · `no-invoices.tsx`

```tsx
import { EmptyState } from "@/components/ui/empty-state";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";

/* a table with no rows: one cell across every column holds the block */
export default function NoInvoices() {
  return (
    <Table className="max-w-[440px]" aria-label="Invoices">
      <TableHeader>
        <TableRow>
          <TableHead>Invoice</TableHead>
          <TableHead>Date</TableHead>
          <TableHead numeric>Amount</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell colSpan={3}>
            <EmptyState size="block" icon="file" title="No invoices yet" hint="Your first invoice arrives on Dec 1, 2026." />
          </TableCell>
        </TableRow>
      </TableBody>
    </Table>
  );
}
```

Vue · `no-invoices.vue`

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

<!-- a table with no rows: one cell across every column holds the block -->
<template>
  <Table class="max-w-[440px]" aria-label="Invoices">
    <TableHeader>
      <TableRow>
        <TableHead>Invoice</TableHead>
        <TableHead>Date</TableHead>
        <TableHead numeric>Amount</TableHead>
      </TableRow>
    </TableHeader>
    <TableBody>
      <TableRow>
        <TableCell :colspan="3">
          <EmptyState size="block" icon="file" title="No invoices yet" hint="Your first invoice arrives on Dec 1, 2026." />
        </TableCell>
      </TableRow>
    </TableBody>
  </Table>
</template>
```

Svelte · `no-invoices.svelte`

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

<!-- a table with no rows: one cell across every column holds the block -->
<Table class="max-w-[440px]" aria-label="Invoices">
  <TableHeader>
    <TableRow>
      <TableHead>Invoice</TableHead>
      <TableHead>Date</TableHead>
      <TableHead numeric>Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell colspan={3}>
        <EmptyState size="block" icon="file" title="No invoices yet" hint="Your first invoice arrives on Dec 1, 2026." />
      </TableCell>
    </TableRow>
  </TableBody>
</Table>
```

## Recipe

`empty-state.recipe.ts`:

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

/* empty-state — what a list, a table or a popup shows when there is nothing in it.
 *   row    one line in a list: the height of an option row (--option-height, 30px by default),
 *          padding-inline 8, 12px ink-2 (the icon ink-3); align="center" centres it. A hint that does not fit drops
 *          under the title rather than squeezing it.
 *   block  a centred stack for a popup or a table body: 32px icon tile, 13px/500 ink title,
 *          12px ink-2 hint, padding 32/16; always centred (block comes after align, so it wins).
 *          The tile is a hover-grey square with a soft hairline: in dark mode the inset grey sat
 *          below the surface with a lighter ring around it, a hole with a bright edge (the heaviest
 *          mark of the block).
 * action   what to do next (a Button, "New issue", "Clear filters"): under a block's text, at the end
 *          of a row's line. The host passes the real Button; nothing here styles it.
 * Author text reads in its own direction (plaintext); a start-aligned row keeps its alignment on
 * the page's side (physical, from the element's own direction, which plaintext does not change).
 *
 * Motion: it fades in at duration.base when it is shown out of `hidden` after its first paint (or
 * inserted with data-enter); data-enter arrives after the first paint (lib/paint.ts), so never on
 * first paint, never on the way out. data-enter is the shared flag of lib/paint.ts and stays an
 * attribute. */

export const emptyState = tv({
  slots: {
    base: [
      "flex min-w-0 items-center gap-2 min-h-[var(--option-height,30px)] px-2",
      "text-xs leading-[1.3] text-ink-2 wrap-anywhere",
      "opacity-100 motion-opacity-base data-enter:starting:opacity-0",
    ],
    icon: "inline-flex shrink-0 items-center justify-center text-[14px] text-ink-3",
    title: "m-0 min-w-0 [unicode-bidi:plaintext]",
    hint: "m-0 min-w-0 [unicode-bidi:plaintext]",
    action: "flex flex-wrap items-center gap-2",
  },
  variants: {
    align: {
      start: { base: "justify-start text-start" },
      center: { base: "justify-center text-center" },
    },
    size: {
      row: {
        base: "flex-wrap gap-y-0.5 py-1.5",
        title: "flex-[0_1_auto]",
        hint: "flex-[0_1_auto]",
        action: "ms-auto",
      },
      block: {
        base: "flex-col justify-center gap-1 px-4 py-8 text-center",
        icon: "size-8 mb-1.5 rounded-control bg-hover shadow-[0_0_0_1px_var(--fndn-line-soft)] text-[15px]",
        title: "text-sm font-medium text-ink",
        hint: "text-xs text-ink-2",
        action: "justify-center mt-2.5",
      },
    },
    /* a row's title followed by a hint ends in " ·" */
    hint: { true: {} },
  },
  compoundVariants: [
    { size: "row", hint: true, class: { title: "after:content-['_·']" } },
    {
      size: "row",
      align: "start",
      class: {
        title: "[&:dir(ltr)]:text-left [&:dir(rtl)]:text-right",
        hint: "[&:dir(ltr)]:text-left [&:dir(rtl)]:text-right",
      },
    },
  ],
  defaultVariants: { size: "row", align: "start" },
});

export type EmptyStateRecipeProps = VariantProps<typeof emptyState>;
```
