---
title: Empty
description: Present an empty or unavailable application state with optional
  media and actions.
package: moraine
version: 0.11.0
repository: https://github.com/subframe7536/moraine
---

# Empty

> Present an empty or unavailable application state with optional media and actions.

## Anatomy

```text
Empty [component; slot=root]
├── Empty.Media [part; slot=media]
├── Empty.Title [part; slot=title]
├── Empty.Description [part; slot=description]
└── Empty.Actions [part; slot=actions]
```

## Usage

Use Empty when a collection or search result is genuinely empty and the next action should be
visible. It does not inspect data; the page decides when to render it. Use
[Skeleton](https://moraine.subf.dev/components/skeleton.md) while content is still loading.

```tsx
import { Empty } from 'moraine'

export function Example() {
  return (
    <Empty>
      <Empty.Title>No projects yet</Empty.Title>
      <Empty.Description>Create a project to organize your work.</Empty.Description>
    </Empty>
  )
}
```

### Parts

Compose only the parts you need. All parts belong inside `Empty`. `Media` accepts arbitrary JSX,
including Icon, Avatar, AvatarGroup, and images; it does not impose a fixed media size or background.

The root and its parts render a `div` by default, except `Empty.Description`, which renders a `p`.
Every part accepts `as`. Set a heading such as `as="h2"` on `Empty.Title` when the surrounding page
needs one. Empty adds no role or ARIA relationships automatically.

```tsx
<Empty>
  <Empty.Media>
    <Icon name="i-lucide:inbox" />
  </Empty.Media>
  <Empty.Title as="h2">Inbox is empty</Empty.Title>
  <Empty.Actions>
    <Button>New message</Button>
  </Empty.Actions>
</Empty>
```

### Sizes

The `sm`, `md` (default), and `lg` sizes change padding, spacing, typography, and action gaps
together. Use `sm` within a Card or table, `md` for ordinary content, and `lg` for a page-level
empty state. Set `size` on `Empty`; the parts inherit it. Vertical padding is larger than horizontal
padding, and media and actions get extra space around them. Size does not resize the content placed
inside `Media`.

```tsx
<Empty size="sm">
  <Empty.Title>No rows</Empty.Title>
</Empty>
```

## Examples

### Prompt a first project

Show Empty when the collection is genuinely empty, not while it is still loading.

```tsx
import { Empty, Icon } from 'moraine'

export function Basic() {
  return (
    <Empty>
      <Empty.Media>
        <Icon name="i-lucide-folder-open" class="text-muted-foreground size-8" />
      </Empty.Media>
      <Empty.Title>No projects yet</Empty.Title>
      <Empty.Description>Create a project to organize your work.</Empty.Description>
    </Empty>
  )
}
```

### Start a conversation from an empty inbox

Put the next useful command in `Empty.Actions`. Wire those buttons to application handlers.

```tsx
import { Button, Empty, Icon } from 'moraine'

export function Actions() {
  return (
    <Empty>
      <Empty.Media>
        <Icon name="i-lucide-inbox" class="text-muted-foreground size-8" />
      </Empty.Media>
      <Empty.Title>Your inbox is empty</Empty.Title>
      <Empty.Description>Start a conversation with your team.</Empty.Description>
      <Empty.Actions>
        <Button>New message</Button>
        <Button as="a" href="#usage" variant="outline">
          Learn more
        </Button>
      </Empty.Actions>
    </Empty>
  )
}
```

### Recover from an empty search

Your search logic decides when to render this message. Offer a way to clear the query.

```tsx
import { Button, Empty, Icon, Input } from 'moraine'
import { createSignal } from 'solid-js'

export function NoResults() {
  const [search, setSearch] = createSignal('design systems')
  return (
    <div class="max-w-md w-full">
      <Input
        value={search()}
        onInput={(event) => setSearch(event.currentTarget.value)}
        aria-label="Search projects"
        placeholder="Search projects"
      />
      <Empty size="sm">
        <Empty.Media>
          <Icon name="i-lucide-search" class="text-muted-foreground size-6" />
        </Empty.Media>
        <Empty.Title>No matching projects</Empty.Title>
        <Empty.Description>Try a different keyword or clear your search.</Empty.Description>
        <Empty.Actions>
          <Button variant="outline" size="sm" disabled={!search()} onClick={() => setSearch('')}>
            Clear search
          </Button>
        </Empty.Actions>
      </Empty>
    </div>
  )
}
```

### Invite the first team members

Place avatars or an illustration in `Media`. The layout stays the same.

```tsx
import { AvatarGroup, Button, Empty } from 'moraine'

export function RichMedia() {
  return (
    <Empty>
      <Empty.Media>
        <AvatarGroup
          items={[
            { text: 'Alex', alt: 'Alex' },
            { text: 'Sam', alt: 'Sam' },
            { text: 'Jo', alt: 'Jo' },
          ]}
          size="lg"
        />
      </Empty.Media>
      <Empty.Title>No team members yet</Empty.Title>
      <Empty.Description>Invite your collaborators to work together.</Empty.Description>
      <Empty.Actions>
        <Button>Invite members</Button>
      </Empty.Actions>
    </Empty>
  )
}
```

### Frame a missing reports section

Empty has no default border, background, shadow, or fixed height. Apply container styling with
`class` and `style`. A part's own `class` and `style` take precedence over the root `classes` and
`styles`. Set `as` on the root to change its element, such as `section` with an `aria-label`.

```tsx
import { Button, Empty, Icon } from 'moraine'

export function CustomContainer() {
  return (
    <Empty
      as="section"
      aria-label="Saved reports"
      class="border border-border rounded-xl border-dashed bg-muted/30"
      classes={{ description: 'max-w-xs' }}
    >
      <Empty.Media>
        <Icon name="i-lucide-chart-no-axes-combined" class="text-muted-foreground size-8" />
      </Empty.Media>
      <Empty.Title as="h2">No saved reports</Empty.Title>
      <Empty.Description>
        Save a report to revisit the metrics that matter to you.
      </Empty.Description>
      <Empty.Actions>
        <Button variant="outline">Create report</Button>
      </Empty.Actions>
    </Empty>
  )
}
```

## API Reference

### Props

#### Empty

Props for Empty.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| size | 'sm' \| 'md' \| 'lg' \| undefined | 'md' | Density and typography of all Empty parts. |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Empty-state parts and direct content. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| classes | Classes \| undefined | — | Family slot class defaults for this instance. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |
| styles | Styles \| undefined | — | Family slot style defaults for this instance. |

#### Empty.Media

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Empty.Title

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Empty.Description

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | T \| undefined | 'p' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |

#### Empty.Actions

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | T \| undefined | 'div' | Element or component to render as. |
| children | JSX.Element \| undefined | — | Content rendered inside the element. |
| class | SlotClassValue \| undefined | — | Class applied to the component root or trigger element. |
| style | SlotStyleValue \| undefined | — | Style applied to the component root or trigger element. |
