import { Button } from "@senvenli/react/action";
import { EmptyState } from "@senvenli/react/feedback";
export default function Example() {
return (
<EmptyState
icon="file-text"
title="No invoices yet"
description="Invoices you send to customers appear here with their status."
primaryAction={<Button variant="primary" iconBefore="plus">Create invoice</Button>}
secondaryAction={<Button variant="subtle">Import from CSV</Button>}
/>
);
}import { EmptyState } from "@senvenli/react/feedback";Examples
No results
Repeats the query and offers the way back.import { Button } from "@senvenli/react/action";
import { EmptyState } from "@senvenli/react/feedback";
export default function Example() {
return (
<EmptyState
icon="search-x"
title="No customers match “lovelace ltd”"
description="Check the spelling, or clear the filters to see every customer."
primaryAction={<Button>Clear filters</Button>}
/>
);
}Compact
The smaller size, for a card or a table.import { EmptyState } from "@senvenli/react/feedback";
import { Box } from "@senvenli/react/layout";
export default function Example() {
return (
<Box radius="large" border>
<EmptyState
size="small"
icon="message-square"
title="No comments yet"
description="Comments from your team appear here."
/>
</Box>
);
}Check your inbox
A confirmation with a resend that waits between sends (`useCooldownAction`).import { Button } from "@senvenli/react/action";
import { EmptyState } from "@senvenli/react/feedback";
import { useCooldownAction } from "../otp-field/use-cooldown-action";
// After "Forgot your password?": the same message whether or not the account exists, and a resend that waits.
export default function Example() {
// The first link was just sent, so the wait is already running (pass 0 when the screen shows later).
const resend = useCooldownAction(() => new Promise((done) => setTimeout(done, 600)), 60, 60);
return (
<EmptyState
icon="mail-check"
title="Check your inbox"
description="If an account exists for that email, we sent a link to reset the password."
primaryAction={
<Button isDisabled={resend.remaining > 0} isPending={resend.isPending} onPress={() => void resend.run()}>
{resend.remaining > 0 ? `Resend in ${resend.remaining}s` : "Resend link"}
</Button>
}
secondaryAction={<Button variant="subtle">Back to sign in</Button>}
/>
);
}A failed load
`tone="danger"` replaces the region that failed, announces it and offers a retry.import { Button } from "@senvenli/react/action";
import { EmptyState } from "@senvenli/react/feedback";
import { useState } from "react";
// A failed load: the danger tone, the message announced, the code for support, and a retry that shows it is busy.
export default function Example() {
const [retrying, setRetrying] = useState(false);
const retry = async () => {
setRetrying(true);
try {
await new Promise((resolve) => setTimeout(resolve, 800));
} finally {
setRetrying(false);
}
};
return (
<EmptyState
tone="danger"
icon="cloud-off"
announce
title="Orders could not be loaded"
description="Check your connection and try again. Your filters are kept."
details={
<span className="font-ds-mono text-body-small text-ds-text-subtlest">
Error code: <bdi>ORD-504</bdi>
</span>
}
primaryAction={
<Button iconBefore="rotate-cw" isPending={retrying} onPress={() => void retry()}>
Retry
</Button>
}
/>
);
}Guidelines
When to use it
- A list or view has nothing to show yet, no results, or failed to load (tone="danger").
Use something else when
Do and avoid
- Never blame the user; say what will appear and how to get it.
Accessibility
Built in
- With announce, the message (title, description, details) is an alert; the actions stay outside it.
You provide
- A heading level when the state is the page's main content.
- For a failed load, a retry Button that shows its pending state (see the example).
API reference
EmptyState
| Prop | Type | Default | Description |
|---|---|---|---|
iconRequired | IconName | – | One Lucide icon; no illustrations. |
titleRequired | React.ReactNode | – | First use: what will appear here. No results: repeat the query. Cleared: the calm confirmation. |
headingLevel | StateHeadingLevel | – | Renders the title as a heading where the state is the page's main content; a plain line by default. |
description | React.ReactNode | – | How the content gets here, or the fix; one or two sentences. Never blame the user. |
primaryAction | React.ReactNode | – | The action that fills the view ( |
secondaryAction | React.ReactNode | – | |
size | StateSize | "medium" |
|
tone | "neutral" | "danger" | "neutral" |
|
details | React.ReactNode | – | Extra lines inside the message, under the description: an error code and when it happened, for support. |
announce | boolean | – | Announce the message (title, description, details) as an alert; the actions stay outside it. For a state that replaces content the user was waiting for (a failed load); not for a first-use or no-results state. |
iconRequiredIconNameOne Lucide icon; no illustrations.
titleRequiredReact.ReactNodeFirst use: what will appear here. No results: repeat the query. Cleared: the calm confirmation.
headingLevelStateHeadingLevelRenders the title as a heading where the state is the page's main content; a plain line by default.
descriptionReact.ReactNodeHow the content gets here, or the fix; one or two sentences. Never blame the user.
primaryActionReact.ReactNodeThe action that fills the view (
Button variant="primary"), or "Clear filters" for no results.secondaryActionReact.ReactNodesizeStateSizeDefault"medium"compactinside tables and cards.tone"neutral" | "danger"Default"neutral"dangerfor a load that failed or a page that is not allowed: the icon in the danger tone.detailsReact.ReactNodeExtra lines inside the message, under the description: an error code and when it happened, for support.
announcebooleanAnnounce the message (title, description, details) as an alert; the actions stay outside it. For a state that replaces content the user was waiting for (a failed load); not for a first-use or no-results state.