Empty State
FreeFull-page or inline empty states with icons or illustrations, titles and action buttons — dashed, ghost-preview and glow variants, five sizes, an onboarding checklist, a search echo with suggestions, and a reason (no data, no results, error, no access) that picks the right copy.
</>sv-empty-state emptyplaceholderfeedback
import { SvEmptyStateComponent } from '@styloviz/empty-state';Demo & usage
Basic usage
Usage example — open the gallery for the full interactive demo.
An interactive demo for this component lives in the gallery.
Open live demoMore examples
With actions
example.htmlAngular
9 lines
<!-- The FIRST action is primary and the rest are secondary unless they say otherwise. Three primary buttons side by side is no hierarchy: the user reads all three to find the one the page expects. --> <sv-empty-state icon="folder" title="No projects yet" message="Create your first project to get started." [actions]="emptyActions" (actionClick)="create()" />
A filtered zero, which is a different fact
example.htmlAngular
14 lines
<!-- "Nothing here yet" when the user has filtered is a lie that reads as a bug: it tells a customer with 4,000 orders they have none because they mistyped a search term - and the cheerful inbox glyph agrees with it. Pass the filters and the copy becomes "No matching results", the glyph becomes a search, and the filters themselves are echoed with one button to drop them. The reason is inferred from them, so the mistake of echoing filters under "Nothing here yet" is impossible. --> <sv-empty-state [activeFilters]="activeFilterLabels()" (clearFilters)="resetFilters()" [actions]="emptyActions" (actionClick)="create()" />
The other two reasons
example.htmlAngular
4 lines
<!-- An error and a permission wall are not empty containers either; each gets its own copy and glyph. --> <sv-empty-state reason="error" /> <sv-empty-state reason="no-access" />
When to use
Communicating that a list, search or section has no content — and what to do next. First-run states, empty searches, cleared inboxes. For load failures specifically, use the Result component (error status). Not sure this is the right outcome surface? Compare toast, banner, result, empty state, notification center and modal by severity, persistence and whether the user can correct it in the “Choosing a feedback pattern” guide under Guides.
Compare with
- Result Page — Result reports how an action ended — success, error, warning — as a page of its own. Empty State is a region with nothing in it yet, the reason, and what to do next.
Async states
- retry
- offline
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| title | string | '' | Main heading text. Falls back to copy chosen from `reason`. Empty by default, so the heading matches the reason: a filtered list says nothing matched the filters rather than `'Nothing here yet'`. |
| message | string | '' | Supporting message under the title. Falls back to copy from `reason`. |
| reason | EmptyStateReason | 'no-data' | Why this container has nothing in it. Drive it from whether a filter or search is active — not from the row count. |
| activeFilters | readonly string[] | [] | The filters currently narrowing the list, in the user's words — `['Status: Overdue', 'Owner: Dana']`. Echoing them turns a dead end into one click. "No matching results" is unanswerable on its own: the user cannot see WHY, and the filter that is hiding everything is usually one they set three screens ago and have forgotten. Naming them, with a way to drop them, is the whole fix. Strings, not a filter model. Only the host can render a date range or a facet id as words a person recognises, and a kit that tried would print `status_id: 4`. |
| clearFiltersLabel | string | null | 'Clear filters' | Label for the built-in clear-filters button. `null` renders none. |
| offline | boolean | false | The device is offline. Takes precedence over `reason`. |
| retryLabel | string | null | null | Label for the preset's retry button, offered for `reason="error"` and for `offline` — the two causes a second attempt can fix. `null` renders none. |
| icon | EmptyStateIcon | 'inbox' | Built-in icon preset. Set to `'custom'` and provide `customIcon` to use your own SVG. |
| customIcon | string | '' | Icon-library NAME — required when `icon === 'custom'`, ignored otherwise. An unresolved name draws no `<svg>` at all, so the decorative ring keeps its shape. |
| showRings | boolean | true | Show the decorative concentric-ring background behind the icon. |
| size | EmptyStateSize | 'md' | Overall size. |
| layout | EmptyStateLayout | 'vertical' | Content stacking axis. |
| bordered | boolean | true | Whether to render a card surface (border + background + rounded corners) or let the component blend into its parent. |
| customClass | string | '' | Additional CSS classes on the root element. |
| actions | EmptyStateAction[] | [] | CTA buttons rendered below the message. Maximum 3 — first one is typically primary, rest secondary/ghost. |
| variant | EmptyStateVariant | 'default' | The card's treatment: plain, dashed, ghost preview, or glow. |
| align | EmptyStateAlign | 'center' | Centred, or aligned to the start of its box. |
| illustration | EmptyStateIllustration | null | null | A built-in illustration in place of the ring stack — or `'auto'` to pick one by `reason`. Projected `[svIllustration]` content wins over this. |
| steps | readonly EmptyStateStep[] | [] | An onboarding checklist: numbered steps, a check on the done ones. |
| query | string | '' | The search that found nothing. With `reason="no-results"` and no `title`, the title says "No results for «query»", and a Clear search button appears. |
| suggestions | readonly string[] | [] | "Did you mean" chips for a search with no results. |
| errorDetails | string | '' | Technical detail for an error, behind a "Show details" disclosure. |
| requestAccessLabel | string | '' | With `reason="no-access"`, a button to ask for access. |
| secondaryLink | EmptyStateLink | null | null | A quiet link under the actions — documentation, a guide. |
| avatars | readonly EmptyStateAvatar[] | [] | People to show in an "invite teammates" stack. |
| maxAvatars | number | 4 | How many avatars to draw before a "+N" chip. |
| shortcut | string | '' | A keyboard shortcut to mention — `'mod+n'` — drawn as keys. |
| shortcutHint | string | '' | What the shortcut does, after it: "to create a project". |
| labels | Partial<SvEmptyStateLabels> | {} | Every string the component renders itself. Merged over `SV_EMPTY_STATE_LABELS`. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| actionClick | string | Emitted when any action button is clicked, carrying the action's `id`. |
| clearFilters | void | The built-in clear-filters button was pressed. |
| retry | void | The preset retry button was pressed (`retryLabel`). |
| stepClick | EmptyStateStep | A checklist step was chosen. |
| suggestionClick | string | A "Did you mean" suggestion was chosen. |
| clearQuery | void | The Clear search button. |
| requestAccess | void | The request-access button. |
Customization & theming
Inline or full-page layout; five sizes (`xs` is a one-line table row, `xl` a full-page hero), `layout` (`vertical` · `horizontal`) and `align` (`center` · `start`). Icon, title, description and actions. `variant`: `default`, `dashed` (with exactly one action the whole card is that action — "Create your first project"), `ghost` (your `[svGhost]` content faintly behind, a preview of the filled screen) or `glow` (a soft tinted glow behind the icon). A built-in `illustration` (`auto` follows `reason`), or your own `[svIllustration]` art or `[svMedia]` content in its place. Extras, each off until set: an onboarding `steps` checklist (`(stepClick)`), the `query` that found nothing with a Clear search button and "did you mean" `suggestions`, `errorDetails` behind a disclosure, `requestAccessLabel` for `no-access`, a quiet `secondaryLink`, an `avatars` stack (`maxAvatars`), and a `shortcut` drawn as keys with its `shortcutHint`. `reason` (`no-data` · `no-results` · `error` · `no-access`) picks the copy AND the glyph when you do not state them — a cheerful inbox over "no matching results" says "you have nothing" when the truth is "your filters match nothing". Passing `[activeFilters]` infers `no-results` by itself. `[activeFilters]` echoes the filters narrowing the list, as chips, with a `(clearFilters)` button beside them: "No matching results" is unanswerable on its own, and the filter hiding everything is usually one the user set three screens ago. Strings rather than a filter model, because only the host can render a date range as words a person recognises. Action hierarchy by position: the first action is primary, the rest secondary, unless an action states its own `style`. `[offline]` takes precedence over `reason`, and `retryLabel` with `(retry)` offers a second attempt for `reason="error"` and for offline — the two causes one can fix. 12 built-in icon presets, or `icon="custom"` with `customIcon` naming any icon-library glyph. An unstated icon follows `reason`.
Best practices
Do: Set `reason` from what actually happened — a search or filter being active, a failed request, a permission check — not from the row count. First use, no results for this filter, no permission and an error each get their own copy and glyph, and "Nothing here yet" is right for exactly one of those four. Use `[offline]` when the device cannot reach the data at all. Do: For a filtered zero, echo the active filters and offer to clear them. It is the difference between a dead end and one click. Do: Pair the empty message with a clear primary action to move forward. Do: Distinguish "no data yet" from "no results for this filter". Don't: Don't leave a blank area — an empty state reassures users nothing is broken.
Accessibility
Clear heading hierarchy. Decorative icon hidden from assistive tech. Actions are labelled buttons/links. Long localized text wraps: the title is capped at `max-w-xl` and both title and description use `hyphens-auto` plus `wrap-anywhere`, so a German or Finnish compound breaks (at a syllable where the browser knows the page `lang`) instead of pushing the centred layout off a 320px screen — WCAG 1.4.10 reflow.
Feedback on Empty State
Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.