0 of 3 environments match
GhostEmptyState
GhostEmptyState is a presentational block for regions with nothing to show: an empty table body, a filter with no matches, or an unused panel. It provides title, description, optional visual, and optional actions in a predictable reading order. The consumer owns why the region is empty; there are no built-in mode enums.
Import it from @ghostvue/themes for the default visual treatment. For headless markup with your own styles, see Advanced: headless composition.
Recover from an empty search
Filter with no matches shows a themed GhostEmptyState; clearing it restores the list, a status line announces the result count, and focus returns to the filter.
The deployment filter starts with a query that matches nothing, so the themed GhostEmptyState from @ghostvue/themes (as="section") replaces the list with a decorative visual, a heading, a description that names the query, and a Clear filter action. Clearing the filter, or pressing Reset beside it, brings the list back.
The empty state itself is static copy and is not a live region. The result count above it is: one role="status" line stays mounted and changes in place from "0 of 3 environments match" to "Showing all 3 environments", so assistive technology hears the outcome of each edit. Both clear buttons unmount once the filter is empty, so the example returns focus to the filter input instead of leaving it on the page body.
Invite a first action
Visual, title, description, and actions with default CSS.
An unused panel pairs a visual, title, and description with one primary action. The themed wrapper sets data-themed on the inner root so default CSS applies without an extra element between table structures.
Table body cell
The default root is a div, which is valid inside a td. Put the empty state in a cell that spans every column, and use as="section" only when you need a landmark and the parent context allows it. The headless table cell example shows the markup.
Accessibility
- Provide a
#titlewhen the empty region needs a programmatic name. - Keep meaningful text in
#titleor#description; visuals are decorative. - Do not use
role="status"on the root; empty copy is static unless the consumer adds a live region. - Pair with table captions or grid counts on the data widget, not inside this primitive.
See the specification for the full contract.
Advanced: headless composition
For teams that bring their own design system, the headless GhostEmptyState from @ghostvue/vue renders the same parts with no styles.
Basic use
Title and description for an unused panel.
When as="section" and the #title slot is present, the root links to the heading with aria-labelledby. A default div root never sets aria-labelledby (generic role cannot be named that way). The visual wrapper is aria-hidden so icons do not duplicate the title in the accessibility tree.
Filtered results with actions
Copy and an action when filters hide every row.
Actions stay in the #actions slot. Use native buttons and links; the empty state does not wrap them in a toolbar role.
Headless table body cell
EmptyState inside a colspan cell.
Composable
useGhostEmptyState bindings on a custom host.
useGhostEmptyState returns as, headingTag, titleId, and rootProps for custom hosts that still follow the part contract.
API
| Prop | Type | Default | Description |
|---|---|---|---|
as | GhostEmptyStateElement | "div" | Root element. Prefer div inside table cells. |
headingLevel | GhostEmptyStateHeadingLevel | 3 | Heading level wrapping the title slot. |
| Slot | Slot props | Description |
|---|---|---|
actions | — | Optional buttons or links; not a tab stop itself. |
description | — | Optional supporting copy in a div wrapper. |
title | — | Optional heading copy. Rendered as h1–h6 from headingLevel. |
visual | — | Optional decorative graphic. Wrapper is aria-hidden. |
@ghostvue/themes adds no props, events, or slots to the headless GhostEmptyState API, which it forwards.
Native attributes fall through to the root. The component sets class, data-ghost-empty-state, data-part="root", and aria-labelledby when as="section" and a title is present.
The root exposes element: HTMLElement | null through a template ref.