# Empty state

> A message and primary action for views that have nothing to show yet.

Use an empty state where a list, table or page has nothing to show: say what is missing, why, and give the one action that fills it.

Pro example source is available to licensed users. See [Pro access](/docs/pro/access).

## Installation

Pro components install from the Aloxe registry with the shadcn CLI. Once per project, add the registry to `components.json` and put a [registry token](/account/tokens) in the `ALOXE_TOKEN` environment variable. [Registry](/docs/pro/registry) has the details.

```json
{
  "registries": {
    "@aloxe": {
      "url": "https://<aloxe-site>/r/{name}.json",
      "headers": { "Authorization": "Bearer ${ALOXE_TOKEN}" }
    }
  }
}
```

Then add the component:

```bash
npx shadcn@latest add @aloxe/empty-state
```

The CLI copies the source into `components/ui/aloxe/`, so it never overwrites your own `ui` components. It also installs `@aloxe/react`, `@aloxe/tokens` and `@base-ui/react`.

Import the tokens once in your global stylesheet, after Tailwind, and add an `@source` for the copied files and one for `@aloxe/react`, so Tailwind generates their classes. `@source` paths are relative to the stylesheet; these assume `src/app/globals.css` and `src/components/ui/aloxe/`.

```css
@import "tailwindcss";
@import "@aloxe/tokens/aloxe.css";
@import "@aloxe/tokens/tailwind.css";
@source "../components/ui/aloxe";
@source "../../node_modules/@aloxe/react/dist";
```

[Installation](/docs/getting-started/installation) covers the theme and brand attributes.

## Usage

```tsx
import { Button } from "@aloxe/react";
import { FileText } from "lucide-react";
import { EmptyState } from "@/components/ui/aloxe/empty-state";

<EmptyState
  icon={<FileText />}
  title="No invoices yet"
  description="Invoices you send appear here with their status and amount."
  action={<Button>New invoice</Button>}
/>
```

Write the title as a plain statement of what is empty, and the description as what happens next. Pick `headingLevel` to fit the page outline; it is `h3` by default.

## Examples

### No results

After a search or a filter, say what matched nothing and offer the way back. A second, quieter action can follow the primary one.

Pro example source is available to licensed users. See [Pro access](/docs/pro/access).

### Compact, without an action

In a small panel, drop the icon and tighten the padding with `className`. When there is nothing to do, leave out `action`.

Pro example source is available to licensed users. See [Pro access](/docs/pro/access).

## Accessibility

| Key | Action |
| --- | --- |
| Tab | Moves to the action buttons. The message itself isn't focusable. |

- The title is a real heading, so screen reader users find the empty state when they move by heading. Set `headingLevel` so it nests under the section it sits in.
- The icon is decorative and hidden from screen readers.
- When the empty state replaces results after a search, announce it, for example with an `aria-live="polite"` count next to the search field.

## API reference

Renders a `data-aloxe="empty-state"` attribute you can target in CSS. Other props go to the wrapping `<div>`.

**EmptyState** (extends <div>)

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `title` | `ReactNode` |  | Yes | Says what is empty, such as No invoices yet. Rendered as a heading. |
| `description` | `ReactNode` |  |  | One or two sentences: why it is empty and what the action does. |
| `icon` | `ReactNode` |  |  | A 20 px line icon in a tile above the title. Decorative. |
| `action` | `ReactNode` |  |  | The primary action, such as a Button. A second, quieter one may follow. |
| `headingLevel` | `2 \| 3 \| 4` | `3` |  | The title's heading level, to fit the page outline. |
| `children` | `ReactNode` |  |  | Extra content between the description and the action. |
| `className` | `string` |  |  | Merged with the default classes, such as py-8 for a tighter panel. |

## Figma

Matches the **Empty state** component in the Pro Figma file. Its `Title`, `Description` and action map to `title`, `description` and `action`; the icon tile maps to `icon`.

See [Figma](/docs/getting-started/figma) for where to get the file and how its names map to code.

## Pro

Empty state is part of Aloxe Pro. The previews on this page are open to everyone; the Code tab shows the example source once you sign in with a Pro license. See [Access and licenses](/docs/pro/access) and [Pricing](/pricing#pro).
