Feedback
EmptyState
What to show instead of data when there is none: an empty collection, no search results, a load error or “all caught up” — with the next step.
import { EmptyState } from '@reactloom/ui';Examples
Empty collection
A first-run state with a primary and a secondary action.
No projects yet
Projects group your invoices, files and team members.
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".
No customers match “zzz”
Check the spelling or search by email instead.
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.
Couldn’t load invoices
The server did not respond.
All caught up
No approvals are waiting for you.
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
| Prop | Type | Default |
|---|---|---|
titlerequiredRendered as a heading. | ReactNode | — |
descriptionWhy it is empty and what to do next. | ReactNode | — |
iconDecorative. Defaults to the tone’s icon; null hides it. | ReactNode | null | — |
actionsButtons or links. | ReactNode | — |
tone | 'neutral' | 'info' | 'success' | 'warning' | 'danger' | 'neutral' |
headingLevelFit the page’s heading outline. | 1–6 | 3 |
sizesm for cards and table cells, lg for whole pages. | 'sm' | 'md' | 'lg' | 'md' |
liveAnnounce 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.
| Attribute | Values |
|---|---|
[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”).