Data display
EmptyState
Free15.6 KB gzippedA friendly, centered block for "no data", "no results", "error", and first-run moments. Pick a kind for sensible default copy, or build your own from icon (or illustration), title, description, actions, and footer.
Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · No keyboard interaction of its own · Full report
Import
import { EmptyState } from "@vjdesigns/vjdesigns-ui";
Importing only EmptyState adds about 15.6 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.
Examples
No results
kind presets an icon, title and tone for common situations. query names what was searched.
No results for “blue sneakers”
Try a shorter search, or check the spelling.
import { Button, EmptyState } from "@vjdesigns/vjdesigns-ui";
export function NoResults() {
return (
<EmptyState
kind="no-results"
query="blue sneakers"
description="Try a shorter search, or check the spelling."
actions={<Button variant="outline" tone="neutral">Clear filters</Button>}
/>
);
}
First run
Create your first project
Projects keep your designs, tasks and files in one place.
import { Button, EmptyState, PlusIcon } from "@vjdesigns/vjdesigns-ui";
export function FirstRun() {
return (
<EmptyState
kind="first-run"
variant="card"
title="Create your first project"
description="Projects keep your designs, tasks and files in one place."
actions={<Button startIcon={<PlusIcon />}>New project</Button>}
/>
);
}
Error with retry
onRetry adds a retry button; retrying shows its loading state.
Something went wrong
We couldn't load your invoices. Check your connection and try again.
import { useState } from "react";
import { EmptyState } from "@vjdesigns/vjdesigns-ui";
export function ErrorWithRetry() {
const [retrying, setRetrying] = useState(false);
return (
<EmptyState
kind="error"
size="sm"
description="We couldn't load your invoices. Check your connection and try again."
retrying={retrying}
onRetry={() => {
setRetrying(true);
setTimeout(() => setRetrying(false), 1500);
}}
/>
);
}
Accessibility
announce="polite" reads the empty state out when it appears and again when its message changes (try searching for something else), using role="status". headingLevel fits it into the page's heading outline.
No results for “blue sneakers”
Try a different search or clear your filters.
import { useState } from "react";
import { Button, EmptyState, Stack } from "@vjdesigns/vjdesigns-ui";
export function Accessibility() {
const [query, setQuery] = useState("blue sneakers");
return (
<Stack gap={4} align="center">
<Button
size="sm"
variant="outline"
tone="neutral"
onClick={() => setQuery((q) => (q === "blue sneakers" ? "red boots" : "blue sneakers"))}
>
Search for something else
</Button>
<EmptyState kind="no-results" query={query} headingLevel={3} announce="polite" />
</Stack>
);
}
Translated
The kind presets' titles, descriptions and the retry button come from the locale (Japanese here). Each can still be overridden with its own prop.
問題が発生しました
読み込めませんでした。もう一度お試しください。
import { EmptyState, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ja from "@vjdesigns/vjdesigns-ui/locales/ja";
export function Translated() {
return (
<LocaleProvider locale="ja" messages={ja}>
<EmptyState kind="error" headingLevel={3} onRetry={() => {}} />
</LocaleProvider>
);
}
Right to left
The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.
No results
لا توجد نتائج لـ «blue sneakers»
Try a shorter search, or check the spelling.
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";
// NoResults is the "No results" example above.
<LocaleProvider locale="ar" messages={ar}>
<NoResults />
</LocaleProvider>
Usage notes
Accessibility:
- Icons and illustrations are decorative (
aria-hidden); the title and description carry the meaning. - The title is a real heading (
headingLevel, default 2). - With
announce, a visually hidden live region (role="status", orrole="alert"for"assertive") is filled just after mount, so screen readers reliably read the result of a search or filter. Without it, nothing is announced; use that for states present on page load. - If you give the root a landmark
role(e.g."region"), it is labelled by the title automatically.
API reference
EmptyState
| Prop | Type | Default |
|---|---|---|
kindPreset with a default icon, tone, title, and description. Every one of those can still be overridden with its own prop (e.g. to translate). | "no-data""no-results""error""offline""no-access""first-run" | — |
queryFor | string | — |
iconIcon shown large inside the soft tinted blob. Pass a built-in | ReactNode | — |
illustrationCustom art (an SVG or image) that replaces the icon blob. Treated as decorative and hidden from assistive technology, so the title and description must carry the meaning. | ReactNode | — |
titleBold display heading. Overrides the preset title. | ReactNode | — |
headingLevelHeading level, chosen to fit the page outline (e.g. 3 inside a card under an h2). | 123456 | 2 |
descriptionSupporting text under the title. Overrides the preset description. | ReactNode | — |
actionsPrimary and secondary actions, usually | ReactNode | — |
onRetryShows a "Try again" button (first in the actions row) and calls this when it is pressed. Works with any kind; most useful with | () => void | — |
retryLabelLabel of the retry button. Localize it here. | ReactNode | "Try again" |
retryingShows the retry button in its loading state while a retry is in flight. | boolean | false |
footerSmall trailing content, such as a "Learn more" link. | ReactNode | — |
toneColor of the icon blob. | "neutral""primary""info""success""warning""danger" | the preset's tone, otherwise "neutral" |
sizeScale: | "sm""md""lg" | "md" |
alignContent alignment. | "center""start" | "center" |
variantSurface style. | "plain""card""subtle" | "plain" |
announceAnnounce the empty state to screen readers when it appears (or when its message changes, e.g. a new | false"polite""assertive" | false |
announceMessageText announced when | string | — |
Also accepts native <div> attributes, plus className, style and ref.
See what changed in each version in the Changelog.
Accessibility report
EmptyState targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.
axe-core audit (live)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.
Built-in behavior
Keyboard
Not focusable, so there's no keyboard interaction of its own.
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Title | heading | Level from headingLevel |
| Icon | none | aria-hidden="true" |
With announce | status or alert | aria-live polite or assertive |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck. | 2.1.1 (A), 2.1.2 (A) |
| Focus | Focus moves in a logical order, is always visible, and isn't hidden behind sticky headers. | 2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA) |
| Screen readers | Names, roles and states are announced correctly, and status changes are announced without moving focus. | 1.3.1 (A), 4.1.2 (A), 4.1.3 (AA) |
| Color | Meaning never depends on color alone; your own colors meet contrast in both modes. | 1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA) |
| Zoom and reflow | At 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed. | 1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA) |
| Pointer targets | Click and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap. | 2.5.8 (AA), 2.5.5 (AAA) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |