Examples

Empty collection

A first-run state with a primary and a secondary action.

Preview

No projects yet

Projects group your invoices, files and team members.
Example.tsx
import { Button, Card, EmptyState } from '@reactloom/ui';
import { FolderPlus } from 'lucide-react';

export default function Example() {
  return (
    <Card style={{ width: '100%', maxWidth: 520 }}>
      <EmptyState
        icon={<FolderPlus />}
        title="No projects yet"
        description="Projects group your invoices, files and team members."
        actions={
          <>
            <Button>New project</Button>
            <Button variant="secondary">Import from CSV</Button>
          </>
        }
      />
    </Card>
  );
}

No results

Appears after typing, so it is announced with live="polite".

Preview

No customers match “zzz”

Check the spelling or search by email instead.
Example.tsx
import { Button, EmptyState, SearchInput, Stack } from '@reactloom/ui';
import { SearchX } from 'lucide-react';
import { useState } from 'react';

const customers = ['Acme Corp', 'Globex', 'Initech', 'Umbrella', 'Hooli'];

export default function Example() {
  const [query, setQuery] = useState('zzz');
  const results = customers.filter((c) => c.toLowerCase().includes(query.toLowerCase()));
  return (
    <Stack gap="3" style={{ width: '100%', maxWidth: 420 }}>
      <SearchInput aria-label="Search customers" value={query} onValueChange={setQuery} />
      {results.length ? (
        <ul style={{ margin: 0 }}>{results.map((c) => <li key={c}>{c}</li>)}</ul>
      ) : (
        // Appears after typing, so it is announced (live="polite").
        <EmptyState
          size="sm"
          live="polite"
          icon={<SearchX />}
          title={`No customers match “${query}”`}
          description="Check the spelling or search by email instead."
          actions={<Button size="sm" variant="secondary" onClick={() => setQuery('')}>Clear search</Button>}
        />
      )}
    </Stack>
  );
}

Errors and success

tone sets the icon and its colour; the text says what happened.

Preview

Couldn’t load invoices

The server did not respond.

All caught up

No approvals are waiting for you.
Example.tsx
import { Button, Card, EmptyState, SimpleGrid } from '@reactloom/ui';

export default function Example() {
  return (
    <SimpleGrid minChildWidth="15rem" gap="4" style={{ width: '100%' }}>
      <Card>
        <EmptyState size="sm" tone="danger" title="Couldn’t load invoices" description="The server did not respond." actions={<Button size="sm">Try again</Button>} />
      </Card>
      <Card>
        <EmptyState size="sm" tone="success" title="All caught up" description="No approvals are waiting for you." />
      </Card>
    </SimpleGrid>
  );
}

API reference

EmptyState props
PropTypeDefault
titlerequired
Rendered as a heading.
ReactNode—
description
Why it is empty and what to do next.
ReactNode—
icon
Decorative. Defaults to the tone’s icon; null hides it.
ReactNode | null—
actions
Buttons or links.
ReactNode—
tone
'neutral' | 'info' | 'success' | 'warning' | 'danger''neutral'
headingLevel
Fit the page’s heading outline.
1–63
size
sm for cards and table cells, lg for whole pages.
'sm' | 'md' | 'lg''md'
live
Announce when it appears after an action.
'off' | 'polite''off'

Customization

Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.

State attributes

Target these in your CSS to style states without depending on class names.

AttributeValues
[data-size]sm · md · lg
[data-tone]neutral · info · success · warning · danger

Theme tokens it reads

--pl-color-danger-fg --pl-color-fg-default --pl-color-fg-muted --pl-color-info-fg --pl-color-success-fg --pl-color-warning-fg --pl-font-size-lg --pl-font-size-md --pl-font-size-sm

Accessibility

  • The title is a real heading (choose the level that fits the outline), so screen-reader users can find it.
  • Icons are decorative; the title and description carry the meaning, never colour alone.
  • Use live="polite" when the state appears after an action, such as a search with no results.

Usage guidelines

Do

  • Say what happened and what to do next in plain words.
  • Offer the one most useful action first.

Don’t

  • Don’t show an empty state while data is loading — use Skeleton.
  • Don’t blame the user (“You have no…” → “No projects yet”).