EmptyState

Display a placeholder for no data, empty results and first-run states

Usage

EmptyState displays a placeholder when there is nothing to show: empty search results, empty tables, first-run states. Set icon, title and description props:

No results found

We couldn't find anything matching your search. Try adjusting your filters or searching with different keywords to see more results.

Size
Align
import { Button, EmptyState } from '@mantine/core';
import { MagnifyingGlassIcon } from '@phosphor-icons/react';

function Demo() {
  return (
    <EmptyState
      icon={<MagnifyingGlassIcon />}
      title="No results found"
      description="We couldn't find anything matching your search. Try adjusting your filters or searching with different keywords to see more results."
    >
      <EmptyState.Actions>
        <Button variant="default">Reset filters</Button>
      </EmptyState.Actions>
    </EmptyState>
  );
}

Compound components

For full control over the content, use compound components instead of the shorthand props:

No results found

We couldn't find anything matching your search. Try adjusting your filters or searching with different keywords to see more results.

import { Button, EmptyState } from '@mantine/core';
import { MagnifyingGlassIcon } from '@phosphor-icons/react';

function Demo() {
  return (
    <EmptyState>
      <EmptyState.Indicator>
        <MagnifyingGlassIcon />
      </EmptyState.Indicator>
      <EmptyState.Title>No results found</EmptyState.Title>
      <EmptyState.Description>
        We couldn't find anything matching your search. Try adjusting your filters or searching with
        different keywords to see more results.
      </EmptyState.Description>
      <EmptyState.Actions>
        <Button variant="default">Reset filters</Button>
        <Button variant="default">Create new</Button>
      </EmptyState.Actions>
    </EmptyState>
  );
}

Both can be combined, children are rendered after the content from the props. EmptyState.Indicator is always rendered first, and the icon prop replaces it when both are set:

import { MagnifyingGlassIcon } from '@phosphor-icons/react';
import { Button, EmptyState } from '@mantine/core';

function Demo() {
  return (
    <EmptyState icon={<MagnifyingGlassIcon />} title="No results found">
      {/* Rendered after the title */}
      <EmptyState.Actions>
        <Button variant="default">Reset filters</Button>
      </EmptyState.Actions>
    </EmptyState>
  );
}

Variant

Set variant to filled or light to display the icon inside a colored circle, use color to change its color:

No results found

We couldn't find anything matching your search. Try adjusting your filters or searching with different keywords to see more results.

Variant
Color
import { EmptyState } from '@mantine/core';
import { MagnifyingGlassIcon } from '@phosphor-icons/react';

function Demo() {
  return (
    <EmptyState
      variant="light"
      color="blue"
      icon={<MagnifyingGlassIcon />}
      title="No results found"
      description="We couldn't find anything matching your search. Try adjusting your filters or searching with different keywords to see more results."
    />
  );
}

Indicator background

Set withIndicatorBackground to display a neutral circle behind the icon without a variant:

Your cart is empty

Your shopping cart is empty right now. Browse our catalog and add the items you like to get started with your first order.

import { Button, EmptyState } from '@mantine/core';
import { ShoppingCartSimpleIcon } from '@phosphor-icons/react';

function Demo() {
  return (
    <EmptyState withIndicatorBackground icon={<ShoppingCartSimpleIcon />} title="Your cart is empty">
      <EmptyState.Description>
        Your shopping cart is empty right now. Browse our catalog and add the items you like to get
        started with your first order.
      </EmptyState.Description>
      <EmptyState.Actions>
        <Button variant="default">Browse products</Button>
      </EmptyState.Actions>
    </EmptyState>
  );
}

Styles API

EmptyState supports the Styles API; you can add styles to any inner element of the component with the classNames prop. Follow the Styles API documentation to learn more.

No results found

We couldn't find anything matching your search. Try adjusting your filters or searching with different keywords to see more results.

Component Styles API

Hover or focus a selector to highlight its elements

/*
 * Hover or focus a selector
 * to outline its elements
 */

Accessibility

The title prop renders a div by default. If the empty state needs a heading, set order on EmptyState.Title to match the surrounding heading levels:

import { EmptyState } from '@mantine/core';

function Demo() {
  return (
    <EmptyState>
      <EmptyState.Title order={2}>No results found</EmptyState.Title>
    </EmptyState>
  );
}

The indicator is decorative and hidden from screen readers. Put its meaning in the title or description:

import { MagnifyingGlassIcon } from '@phosphor-icons/react';
import { EmptyState } from '@mantine/core';

function Demo() {
  return <EmptyState icon={<MagnifyingGlassIcon />} title="No search results" />;
}

To announce an empty search result, keep the role="status" container mounted and update its contents:

import { EmptyState } from '@mantine/core';

function SearchStatus({ resultCount }: { resultCount: number }) {
  return (
    <div role="status">
      {resultCount === 0 && <EmptyState title="No search results" />}
    </div>
  );
}

Give each action button a descriptive label. For an icon-only button, use aria-label:

import { PlusIcon } from '@phosphor-icons/react';
import { ActionIcon, EmptyState } from '@mantine/core';

function EmptyProjects({ onCreate }: { onCreate: () => void }) {
  return (
    <EmptyState title="No projects yet">
      <EmptyState.Actions>
        <ActionIcon aria-label="Create a project" onClick={onCreate}>
          <PlusIcon />
        </ActionIcon>
      </EmptyState.Actions>
    </EmptyState>
  );
}