Presents information to help users understand why a panel or other container has no content.
For Use In
Lightning Experience, Experience Builder Sites
lightning-empty-state is a pilot or beta service that is subject to the Beta Services Terms at Agreements - Salesforce.com or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the Product Terms Directory. Use of this pilot or beta service is at the Customer’s sole discretion.
Note
The lightning-empty-state component shows content that represents an “empty state” of a container, such as a panel or card, in which your users expect data to appear. Empty states tell users why there’s no content to show and can guide them to what they can do next.
For example, an empty state can reflect these common conditions.
An error prevents content loading
The system is undergoing maintenance
A search or filter returned no results
A shopping cart is empty
A user cleared a list of items
The lightning-empty-state component provides a standardized solution for depicting empty states. Instead of creating custom layouts, styling, and illustration handling, use lightning-empty-state to take advantage of these benefits.
Feature
Developer Benefit
Consistency
Ensures uniform empty state patterns across the platform with automatic design system compliance.
Simplified Development
Provides a ready-to-use component that eliminates the need for custom empty state implementations.
Dynamic Theme Support
Illustrations dynamically adapt to themes, supporting light and dark mode and themes based on SLDS 1 and SLDS 2.
Responsive Design
Built-in responsive behavior that adapts to different container sizes.
Design
lightning-empty-state implements the illustration (empty state) blueprint in the Salesforce Lightning Design System (SLDS). The empty state adapts to SLDS 1 or SLDS 2 styling based on the org’s theme or the container app that you use.
The lightning-empty-state component uses the lightning-illustration component internally to present scalable vector graphics (SVG) illustrations. Both the lightning-empty-state and lightning-illustration components currently support the same sets of Salesforce SVG illustrations for depicting empty state conditions.
Use the lightning-empty-state component to show text to help users understand why a container has no items to show. Optional call-to-action (CTA) controls and content can help users react, and an optional illustration can help to reassure users.
Currently, you can use lightning-illustration for similar use cases as lightning-empty-state where you don’t require the supporting text or call-to-action content. More illustrations are in development for other use cases.
Usage
Use the lightning-empty-state component to present informative text and an optional decorative illustration when a container doesn’t display content. The component provides a friendly and consistent way to help your users understand why there’s no content. You can also add a button to help them take the next action.
The only required content for lightning-empty-state is the description slot. Use the description slot to explain the empty state scenario and, if possible, guide users to the next activity. The description slot gives you flexibility in presenting the information. For example, you can use a simple <p> element, which we recommend. If your use case calls for it, you can use multiple paragraphs or another element such as an unordered list.
Provide an optional title attribute to create a heading that gets attention and tells users what’s happening. Depending on the use case of the empty state notice, titles can be playful, or more direct and terse. The component renders the title in a <h3> element.
Here’s an example that uses lightning-empty-state with a title and description, but not an illustration.
Specify the optional illustration-name attribute to include an SLDS illustration in the empty state component. The component automatically detects the SLDS version of the theme that’s enabled in Salesforce. This detection enables the component to present different illustrations for SLDS 2 and SLDS 1 themes. In SLDS 2 themes, the illustrations also adapt automatically for dark mode and theme and branding that’s in effect in the org.
illustration-name accepts a name in the format set:symbol (which you can think of as category:name) to retrieve an SVG image from SLDS. For example, if your component shows an empty state of a customer’s cart before the customer has placed items in it, specify illustration-name="cart:noitems" to show an illustration of an empty shopping bag.
1<!-- With illustration -->23<lightning-empty-state illustration-name="cart:noitems" title="No items in cart">4 <p slot="description">Add items to get started.</p>5</lightning-empty-state>
Illustrations for SLDS 2 and SLDS 1
The lightning-empty-state component shows a unique SVG image for each illustration that you can specify with the illustration-name attribute. The illustration name follows the category:name pattern, for example, cart:noitems and error:connectionissue.
For SLDS 2 themes, lightning-empty-state uses new Salesforce Cosmos illustrations. For SLDS 1 themes, the component uses a smaller set of existing SLDS 1 illustrations from Lightning Experience.
Each of the SLDS 1 illustrations maps to one of the same category:name illustration names. The mapping enables lightning-empty-state to work in SLDS 1 themes. However, some SLDS 1 illustrations map to multiple illustration names. This reuse of illustrations means that SLDS 1 themes don’t have a unique SVG image for each illustration name.
Map of Illustration Names to Illustrations for SLDS 2 and SLDS 1
These illustration names are available. Visit Empty State component design to see the current images and their use cases. This table describes the images that map to the illustration names to aid you in recalling the images. You can avoid looking them up in the design each time.
Illustration Name
SLDS 2
SLDS 1
access:deleted
A cocoon or chrysalis
An open empty treasure chest
access:limit
An extinguished candle
A closed treasure chest
access:request
A locked padlock
A closed treasure chest
cart:noitems
An empty shopping bag
Gone fishing - Astro and Codey in a canoe
error:appconnection
A stylized balloon
Floating hot air balloons
error:connectionissue
An unplugged electrical plug
Floating hot air balloons
error:recoverable
A wilting plant
A rainy campsite
error:unrecoverable
A rain cloud
A walking path that’s closed
maintenance:planned
A healthy plant
A hand under a landscape
maintenance:unplanned
A boomerang
A hand under a landscape
noresults:filter
Three plants, the tallest bending to the sun
Binoculars with a cracked lens
noresults:search
A telescope pointing away from the sky
Binoculars with a cracked lens
noresults:unknown
Mountains and clouds
Binoculars with a cracked lens
success:assigned
Umbrella planted on a beach
Gone fishing - Astro and Codey in a canoe
success:new
A zen sand garden
Gone fishing - Astro and Codey in a canoe
success:selfassigned
A flag planted on a hill
Gone fishing - Astro and Codey in a canoe
For example, this component automatically shows different illustrations for SLDS 2 themes (an empty shopping bag), and SLDS 1 themes (a “gone fishing” scene).
1<!-- With illustration -->2<lightning-empty-state illustration-name="cart:noitems" title="No items in cart">3 <p slot="description">When you add items to your cart, they’ll appear here.</p>4</lightning-empty-state>
SLDS 2 themes show the empty shopping bag image for the cart:noitems illustration.
SLDS 1 themes show the gone fishing image for the cart:noitems illustration.
Override the Responsive Illustration Size
lightning-empty-state adapts automatically to the container that it’s in, scaling the size of text and illustrations. By default, the component performs responsive sizing by querying the size of the container before setting an illustration size. Based on the size of the container, the component sets one of three sizes: medium, small, and x-small.
Container Type
Container Width
Illustration Size
Illustration Width
Full page or large panel
366 px or more
medium
304 px
Card
256–365 px
small
184 px
Mobile device, small card, nested panels
0–255 px
x-small
No illustration is shown
To override the automatic sizing, you can specify the size attribute with a value of medium, small, or x-small. For example, to make the empty state component render an illustration as small even when it’s in a large panel, set size="small". If you set size to x-small, any illustration you specify doesn’t appear.
The component provides a slot called cta for a call-to-action button. Use lightning-button with slot="cta" to give users a recommended action to perform when presented with an empty state. Use the brand variant to draw attention to the recommended action.
Use an Illustration and an Action Button
This example shows an empty cart illustration along with a Browse Products call-to-action button with the brand variant.
1<!-- myEmptyState.html -->2<!-- With illustration and action -->3<lightning-empty-state illustration-name="cart:noitems" title="No items in cart">4 <p slot="description">Add items to get started.</p>5 <lightning-button variant="brand" label="Browse Products" slot="cta" onclick={handleCtaClick}>6 </lightning-button>7</lightning-empty-state>
1import{LightningElement}from "lwc";23export default class MyEmptyState extends LightningElement{4 handleCtaClick(event){5 // go to the Shop tab6}7}
Use CTA Slot on a Container
For multiple buttons in a call-to-action, use the cta slot on a container element. Use no more than two buttons. If you use two buttons, use the brand variant for the primary action button and the neutral variant for the other button.
The lightning-empty-state component works only on the Salesforce platform. It requires access to the SVG illustrations in a Salesforce org.
The component works in Experience Builder Sites, but can only display SLDS 1 illustrations. SLDS 2 isn’t supported in Experience Cloud.
This component uses new Salesforce Cosmos illustrations to fit the SLDS 2 themes. Develop with the SLDS 2 version of the illustration in mind first, and then test the component with SLDS 1 themes.
Accessibility
The lightning-empty-state component has an optional alternative-text attribute for specifying text for assistive technologies. Use alternative-text if the illustration conveys meaningful information such as why no results appear. Use concise, purposeful text such as “No search results.” Omit alternative-text if the illustration is purely decorative and the title or description communicates the message.
The title renders as an h3 element. If you use lightning-empty-state in a location where a level 3 heading isn’t hierarchically accurate for assistive technologies, use the heading-level attribute to set the level appropriately. Valid heading-level values are 1, 2, 3, 4, 5, and 6.
The illustrations support SLDS standards for high color contrast across all themes.
The call-to-action button is the only interactive element. Use keyboard navigation to get to the call-to-action button, and press Enter or the spacebar to select.
Assistive text that describes the illustration. Provide this text for assistive devices if the description and title aren't meaningful enough by themselves.
string
heading-level
Sets the aria-level value for the <h3> element in the empty state's title element. Specify headingLevel if the implicit value 3 isn't correct for your use case. Supported values are 1, 2, 3, 4, 5, 6.
string | number
illustration-name
The illustration identifier in "set:symbol" format. See the Develop tab for valid illustration names.
string
size
Overrides the automatic illustration sizing. Valid values are x-small, small, medium. The default value is null, which triggers the automatic sizing.
string
title
Text to display as the title in an <h3> element in the component.
string
Slots
Name
Description
cta
Placeholder for the call-to-action button. To use more than one button, use the slot on a <div> container element.
description
Required. Placeholder for the empty state description that's displayed below the illustration and title, if they're present. Use the slot on a <p> element.