Skip to Content
Cristal

Feedback

Empty state

What shows when there is nothing to display, with a way out.

<cr-empty-state>CrEmptyState

Example

cr-empty-state replaces a list, a table or a search with no content: a heading that says what is missing, a description as content that says why and what to do, and buttons in the actions slot to get out of it. illustration adds a small drawing: search (the "no results" magnifier, the same as in search), inbox (empty tray), error or none (default).

The illustration floats gently three times, under 5 seconds in all, then stops.

Try another word or remove some filters.Remove filtersYour invoices will appear here after your first order.Browse the catalogueThe server is not responding. Try again in a moment.Try again
'use client';

import { CrBox, CrButton, CrEmptyState } from '@cristal-ui/react';

export default function EmptyStateBasic() {
  return (
    <CrBox display="flex" direction="column" gap="lg">
      <CrEmptyState heading="No products found" illustration="search">
        Try another word or remove some filters.
        <CrButton slot="actions" variant="outline">
          Remove filters
        </CrButton>
      </CrEmptyState>
      <CrEmptyState heading="No invoices" illustration="inbox">
        Your invoices will appear here after your first order.
        <CrButton slot="actions" href="/docs">
          Browse the catalogue
        </CrButton>
      </CrEmptyState>
      <CrEmptyState heading="Orders could not be loaded" illustration="error">
        The server is not responding. Try again in a moment.
        <CrButton slot="actions" variant="secondary">
          Try again
        </CrButton>
      </CrEmptyState>
    </CrBox>
  );
}

If the user asked their system to reduce motion, the illustration stays still.

Accessibility

  • The illustration is decorative, hidden from screen readers: the heading and the description carry all the meaning.
  • The heading is a bold paragraph, not a section heading: the component cannot know which level fits your page. If the empty state fills the whole page, put a real heading (h1, h2) above it.
  • The empty state is not announced: if it appears after an action (a search, a filter), announce the result elsewhere, for instance in a role="status" region saying "0 results".
  • The motion stops by itself within 5 seconds (WCAG 2.2.2).

API

Properties

PropertyTypeDefaultDescription
heading (obligatoire)string—Titre court, en gras : ce qui manque (« Aucune commande »).
illustration"error" | "inbox" | "none" | "search"'none'Illustration décorative : none (aucune), search (loupe, aucun résultat), inbox (boîte vide) ou error (erreur).

Slots

SlotDescription
defaultLa description : pourquoi c'est vide, et quoi faire.
slot="actions"Les boutons pour sortir de l'état vide.

CSS parts

To style it from outside: cr-empty-state::part(name) { … }

PartDescription
actionsLa zone des boutons.
descriptionLa zone de la description.
headingLe titre.
illustrationL'illustration.

On this page