Status and content

Empty State

Explain why content is missing and give people a useful next step.

Installation

pnpm dlx @mielui/svelte add empty-state

Usage

Root sets spacing and alignment. Header groups Title and Description. Put an icon or image in Media, supporting content in Content, and buttons or links in Actions. Every part is optional and renders where you place it. Root has no border or background, so it can sit inside a table, panel, or page without adding another card.

<script lang="ts">
    import { Button } from '@mielui/svelte/components/button';
    import * as EmptyState from '@mielui/svelte/components/empty-state';
</script>

<EmptyState.Root>
    <EmptyState.Header>
        <EmptyState.Title>No saved reports</EmptyState.Title>
        <EmptyState.Description>
            Save a report to return to it later.
        </EmptyState.Description>
    </EmptyState.Header>
    <EmptyState.Actions>
        <Button href="/reports/new">Create report</Button>
    </EmptyState.Actions>
</EmptyState.Root>

Examples

No search results

An icon, a heading, and a short explanation. Keep search and filter controls in the surrounding application.

Completed work

A confirmation icon marks a completed task. This composition omits Actions and Content.

Accessibility

Title renders an h2 by default; set level to match the surrounding heading outline. Mark decorative icons with aria-hidden on Media and give meaningful images alt text. Every part accepts the attributes and event handlers of the element it renders.

Root does not announce itself or move focus. For changing search results, keep a separate role="status" element mounted and update its text. Keep interactive actions outside that live region. If an action removes the focused control, move focus to the next useful control. Loading and failed requests need their own messages; an empty result should mean the request finished successfully.

API reference

EmptyState.Root

  • children
    Snippet<[]>

    Content rendered inside.

EmptyState.Actions

  • children
    Snippet<[]>

    Content rendered inside.

EmptyState.Content

  • children
    Snippet<[]>

    Content rendered inside.

EmptyState.Description

  • children
    Snippet<[]>

    Content rendered inside.

EmptyState.Header

  • children
    Snippet<[]>

    Content rendered inside.

EmptyState.Media

  • children
    Snippet<[]>

    Content rendered inside.

EmptyState.Title

  • children
    Snippet<[]>

    Content rendered inside.

  • level
    HeadingLevel

    Heading level in the surrounding document.

    Default 2