Skip to main content

Empty

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

No projects yet

Create a project to organize your work.

Learn more
Props
Slots

Anatomy#

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 while content is still loading.

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.

<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.

<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.

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.

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>
  )
}

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

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.

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.

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. Renders a <div> element by default.

Prop

Media#

Renders a <div> element by default.

Prop

Title#

Renders a <div> element by default.

Prop

Description#

Renders a <p> element by default.

Prop

Actions#

Renders a <div> element by default.

Prop