# Empty State

A composed placeholder for zero data, filtered results, and first-run experiences.

Empty State explains why a collection or result region has nothing to show and, when useful, gives the user one clear next step.

```tsx
import { PlusIcon, TrayIcon } from "@phosphor-icons/react";
import { Button, EmptyState } from "@zentara-co/zenos-ui";

function EmptyStatePreviewExample() {
  return (
    <EmptyState className="max-w-2xl rounded-xl border border-border-default bg-background-neutral-card">
      <EmptyState.Header>
        <EmptyState.Media>
          <TrayIcon />
        </EmptyState.Media>
        <EmptyState.Title>No projects yet</EmptyState.Title>
        <EmptyState.Description>
          Create your first project to organize tasks, files, and conversations in one place.
        </EmptyState.Description>
      </EmptyState.Header>
      <EmptyState.Actions>
        <Button size="sm" variant="primary" startIcon={<PlusIcon />}>
          Create project
        </Button>
      </EmptyState.Actions>
    </EmptyState>
  );
}
```

## Import

```tsx
import { EmptyState } from "@zentara-co/zenos-ui";
```

## Anatomy

Compose only the parts the message needs. `EmptyState.Header` keeps the decorative media and copy on a readable measure. `EmptyState.Actions` is optional.

```tsx
<EmptyState>
  <EmptyState.Header>
    <EmptyState.Media>{/* decorative icon */}</EmptyState.Media>
    <EmptyState.Title>No projects yet</EmptyState.Title>
    <EmptyState.Description>Create a project to get started.</EmptyState.Description>
  </EmptyState.Header>
  <EmptyState.Actions>{/* optional action */}</EmptyState.Actions>
</EmptyState>
```

## Choose the right message

Use Empty State for a valid zero-data result: a new workspace, an empty inbox, or a search with no matches. Lead with the condition, explain it in one short sentence, and add an action only when there is a useful next step.

Do not use it while data is still loading; use [Skeleton](/components/skeleton/) or [Loader](/components/loader/). Use [Alert](/components/alert/) for recoverable inline feedback that should not replace the whole content region. When a failed request does replace the region, a destructive empty state may include one retry action.

## Semantic variants

The variant colors only `EmptyState.Media`. The surrounding layout, title, and description stay neutral so status color supports the message instead of becoming the entire surface. Icons are decorative and hidden from assistive technology.

```tsx
import { CheckCircleIcon, MagnifyingGlassIcon, WarningCircleIcon } from "@phosphor-icons/react";
import { EmptyState, Grid } from "@zentara-co/zenos-ui";

function EmptyStateVariantsExample() {
  const states = [
    {
      variant: "info",
      icon: <MagnifyingGlassIcon />,
      title: "No results",
      description: "Nothing matched your current search and filters.",
    },
    {
      variant: "destructive",
      icon: <WarningCircleIcon />,
      title: "Couldn't load projects",
      description: "Check your connection, then try loading this view again.",
    },
    {
      variant: "success",
      icon: <CheckCircleIcon />,
      title: "All caught up",
      description: "There are no outstanding reviews in your queue.",
    },
  ] as const;

  return (
    <Grid columns={{ base: 1, lg: 3 }} gap="4" className="w-full">
      {states.map((state) => (
        <EmptyState
          key={state.variant}
          variant={state.variant}
          density="compact"
          className="rounded-xl border border-border-default bg-background-neutral-card"
        >
          <EmptyState.Header>
            <EmptyState.Media>{state.icon}</EmptyState.Media>
            <EmptyState.Title>{state.title}</EmptyState.Title>
            <EmptyState.Description>{state.description}</EmptyState.Description>
          </EmptyState.Header>
        </EmptyState>
      ))}
    </Grid>
  );
}
```

## Actions

Prefer one small outline action. A primary action is appropriate when the empty state is a first-run experience and the next step is unambiguous. Avoid menus or several competing calls to action; link secondary guidance from the description or the surrounding page instead.

Empty State does not own button behavior. Compose [Button](/components/button/) or [Link](/components/link/) inside `EmptyState.Actions`, preserving their native focus, disabled, and navigation behavior.

## Density

`density="comfortable"` is the default for page and panel states. `density="compact"` reduces the minimum height, padding, media size, and type scale for smaller cards, table regions, and popovers. Density also inherits from `DensityProvider`.

```tsx
import { TrayIcon } from "@phosphor-icons/react";
import { EmptyState, Grid } from "@zentara-co/zenos-ui";

function EmptyStateDensityExample() {
  return (
    <Grid columns={{ base: 1, md: 2 }} gap="4" className="w-full">
      {(["comfortable", "compact"] as const).map((density) => (
        <EmptyState
          key={density}
          density={density}
          className="rounded-xl border border-border-default bg-background-neutral-card"
        >
          <EmptyState.Header>
            <EmptyState.Media>
              <TrayIcon />
            </EmptyState.Media>
            <EmptyState.Title className="capitalize">{density}</EmptyState.Title>
            <EmptyState.Description>
              Density changes spacing and type scale without changing the message.
            </EmptyState.Description>
          </EmptyState.Header>
        </EmptyState>
      ))}
    </Grid>
  );
}
```

## Custom styling

The root is intentionally surface-free. Add a border, background, radius, or width with `className` to match its container. Every part—`Root`, `Header`, `Media`, `Title`, `Description`, and `Actions`—accepts `as`, `className`, `style`, native attributes, event handlers, and a correctly typed ref. Each also exposes a stable `data-slot`, and local classes merge last.

`EmptyState.Media` owns its default bottom margin directly, with no hidden wrapper, so a class such as `mb-0` or `mb-6` can replace it. Use `as` when the default element does not fit the page semantics—for example, render `Title` as `h2`, `Description` as `div`, or `Actions` as `footer`. Prefer semantic tokens to keep light and dark themes aligned.

```tsx
import { PlusIcon } from "@phosphor-icons/react";
import { Button, EmptyState } from "@zentara-co/zenos-ui";

function EmptyStateCustomExample() {
  return (
    <EmptyState
      as="section"
      variant="primary"
      className="max-w-2xl rounded-2xl border border-dashed border-border-brand bg-background-brand-subtlest-default"
      aria-labelledby="custom-empty-state-title"
    >
      <EmptyState.Header as="header" className="max-w-xl gap-3">
        <EmptyState.Media className="mb-6 rounded-full border-border-brand bg-background-neutral-card shadow-sm">
          <PlusIcon />
        </EmptyState.Media>
        <EmptyState.Title as="h2" id="custom-empty-state-title" className="text-text-brand">
          Build your workspace
        </EmptyState.Title>
        <EmptyState.Description as="div" className="max-w-lg text-text-default">
          Add teammates when you are ready. Custom classes change the presentation without changing
          the compound anatomy.
        </EmptyState.Description>
      </EmptyState.Header>
      <EmptyState.Actions as="footer" className="pt-6">
        <Button size="sm" variant="primary">
          Invite teammates
        </Button>
      </EmptyState.Actions>
    </EmptyState>
  );
}
```

## Variants

default, primary, success, warning, info, destructive

## Anatomy

```text
EmptyState.Root
EmptyState.Header
EmptyState.Media
EmptyState.Title
EmptyState.Description
EmptyState.Actions
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| variant | default \| primary \| success \| warning \| info \| destructive | default | Changes the decorative media color while leaving the title, description, and layout neutral. |
| density | comfortable \| compact | comfortable | Controls minimum height, spacing, media size, and type scale. Inherits from DensityProvider when omitted. |
| as | ElementType | — | Changes the rendered element on Root, Header, Media, Title, Description, or Actions and supplies its native prop and ref types. |
| role / aria-live | native ARIA attributes | — | Opt into a live status only when an existing result region changes to an empty state. |
| className | string | — | Merged last on every part for custom surfaces, borders, dimensions, and media treatment. |
| native props | React.HTMLAttributes<HTMLElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

`EmptyState.Title` renders an `h3` by default; keep it in the page's heading order or change it with `as` to match the surrounding section. `EmptyState.Media` is decorative and uses `aria-hidden="true"`, so the title and description must carry the meaning.

The root has no live-region role by default. For an empty state that replaces existing search results after an interaction, keep the region mounted and add `role="status"` with `aria-live="polite"`. Do not announce a static first-run state or duplicate a nearby status message.

Source: https://zenos-ui.pages.dev/components/empty-state/