EmptyState
BasicData display
<co-empty-state>EmptyState fills a screen or card that has nothing to show, including the access-denied screen.
import { EmptyState } from 'health-components';
Examples
Showcase
Empty
Denied
Load Error
Usage
<EmptyState kind="noresults" title="No patients match" actions={<Button>Clear Filters</Button>}>Try the MRN or date of birth.</EmptyState>
When to use
- No data yet, no search results, no access, load failed.
When not to use
- A table with filters applied: use the table empty row.
Variants and states
| Variant | What it is |
|---|---|
| empty | Inbox icon, what will appear here, first action. |
| noresults | Search icon, how to widen the search. |
| denied | Lock icon, the missing permission and who can grant it. |
| error | Red circle, what failed and Try Again. |
| compact | 24px padding, inside cards. |
Accessibility
- denied and error use role alert.
Do and don't
- Do: Denied: name the permission ("Manage claims") and the person (Practice Admin).
- Don't: "Oops!"
- Don't: Hiding the screen from the menu and then showing a denied page from a link: same rule both places.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
kind | EmptyStateKind | 'empty' | 'empty' | 'noresults' | 'denied' | 'error' |
title * | ReactNode | — | Heading (h2). Required |
children | ReactNode | none | Body text: what to do next |
actions | ReactNode | none | Buttons under the body |
icon | IconName | by kind (inbox, search, lock, alert-circle) | Icon |
compact | boolean | false | Less padding, for cards and table bodies |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-empty-state>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-empty-state kind="…" icon="…" [defaultValue]="defaultValue">…</co-empty-state>
| Kind | Name | Description |
|---|---|---|
| attribute | kind | 'empty' | 'noresults' | 'denied' | 'error'; default 'empty' |
| attribute | icon | Icon; default by kind (inbox, search, lock, alert-circle) |
| attribute | compact | Less padding, for cards and table bodies; default false |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| slot | title | Heading (h2). Required Plain text also works as the `title` attribute. |
| slot | (default) | Body text: what to do next; default none |
| slot | actions | Buttons under the body; default none Plain text also works as the `actions` attribute. |