Empty State
<sl-empty-state> | SlEmptyState
An empty state appears when there is no data to display and helps a user understand what they can do next.
<sl-empty-state icon="bullhorn" heading="Heading text for this empty state"> Explainer text for this empty state, this should help the user understand what to do next. <div slot="action"> <sl-button variant="primary">Primary action</sl-button> <sl-button variant="secondary">Secondary action</sl-button> </div>
Examples
Using the icon slot
To use a custom icon, you can put any HTML content in the icon slot:
<sl-empty-state heading="Icon slot empty state"> <img slot="icon" src="/assets/images/firefox.png"/> Explainer text for this empty state, this should help the user understand what to do next. </sl-empty-state>
Loading
To show an empty state that represents a loading state, set the loading
attribute.
<sl-empty-state loading heading="We are fetching your data"></sl-empty-state>
Usage
An empty state can be wrpped in a card or the body of a table or page, its contents should be centered vertcally and horizontally.
<sl-empty-state icon="emoji-frown" heading="Present engaging content"> <img slot="icon" src="/assets/images/empty-state-present.svg"/> To get started, you need to have access to at least one client account. Close this tab and try again. <div slot="action"> <sl-button variant="secondary"> <sl-icon slot="prefix" name="xmark"></sl-icon> Close tab </sl-button> </div> </sl-empty-state> <br/><br/> <sl-card> <sl-empty-state icon="emoji-frown" heading="Heading text for this empty state"> Explainer text for this empty state, this should help the user understand what to do next. <div slot="action"> <sl-button variant="primary">Primary action</sl-button> <sl-button variant="secondary">Secondary action</sl-button> </div> </sl-empty-state> </sl-card> <br/><br/> <sl-card> <div slot="header"> Table Title </div> <sl-empty-state class="xtra-padding"> Explainer text for this empty state, this should help the user understand why there is no data in their table. </sl-empty-state> </sl-card> <style> .xtra-padding { padding: var(--sl-spacing-3x-large); } </style>
Slots
Name | Description |
---|---|
(default) | The default slot is used for the empty state content |
icon
|
A custom icon or image can be added |
heading
|
A heading can be added |
action
|
Actions like buttons can be added |
Learn more about using slots.
Properties
Name | Description | Reflects | Type | Default |
---|---|---|---|---|
icon
|
The icon to show. Leave empty for no icon. |
string
|
''
|
|
heading
|
The heading |
string
|
''
|
|
loading
|
Show as a loading empty state with spinner for the icon |
boolean
|
false
|
|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Learn more about attributes and properties.
Custom Properties
Name | Description | Default |
---|---|---|
--example |
An example CSS custom property. |
Learn more about customizing CSS custom properties.
Parts
Name | Description |
---|---|
base |
The component’s base wrapper. |
Learn more about customizing CSS parts.
Dependencies
This component automatically imports the following dependencies.
<sl-icon>