menumenu_openMDC

Empty State

descriptionREADMEwidgetsDemo

mdc-empty-state presents a centered message inside an empty screen or section. The visual order follows the Android intent resolver. A heading alone works for a simple empty list, as in AndroidX ListFragment. Named slots let applications supply their own content, following the Compose slot API pattern.

import '@sandlada/mdc/components/empty-state/index'
import '@sandlada/mdc/components/icon/index'
import '@sandlada/mdc/components/button/index'
<mdc-empty-state>
    <mdc-icon slot="illustration" name="search_off" aria-hidden="true"></mdc-icon>
    <h2 slot="headline">No matching results</h2>
    <p slot="supporting-text">Try another search or clear your filters.</p>
    <mdc-button slot="actions" variant="filled">Clear filters</mdc-button>
</mdc-empty-state>
Slot Content
illustration Optional image or icon. Use alt="" on a decorative image or aria-hidden="true" on a decorative icon.
headline Use the heading level that fits the surrounding page.
supporting-text Optional explanation or next step.
actions Optional buttons or links. Multiple actions wrap as space narrows.

Place each slotted element directly inside mdc-empty-state. The application controls visibility with the native hidden attribute or conditional rendering and handles actions through the controls' normal events.

Override --mdc-empty-state-enabled-headline-color, --mdc-empty-state-enabled-supporting-text-color, or --mdc-empty-state-enabled-illustration-color to theme the content. --mdc-empty-state-container-max-inline-size controls the maximum content width.

Actions

Code
<mdc-empty-state>
    <mdc-icon slot="illustration" name="search_off" aria-hidden="true"></mdc-icon>
    <h3 slot="headline">No matching results</h3>
    <p slot="supporting-text">Clear your filters to show all projects.</p>
    <mdc-button slot="actions" variant="filled" onclick="
        const emptyState = this.closest('mdc-empty-state')
        const results = emptyState.nextElementSibling
        results.hidden = false
        emptyState.hidden = true
        results.focus()
    ">Clear filters</mdc-button>
</mdc-empty-state>
<p hidden tabindex="-1">Showing all projects.</p>

Headline

Code
<mdc-empty-state>
    <h3 slot="headline">No saved items</h3>
</mdc-empty-state>