# EmptyState
Package: @mantine/core
Import: import { EmptyState } from '@mantine/core';
Description: 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:

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


function Demo() {
  return (
    <EmptyState
       size="md" align="center" withIndicatorBackground={false}
      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:

```tsx
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:

```tsx
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:

```tsx
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."
    />
  );
}
```


## Accessibility


If the empty state needs a heading, set `order` on `EmptyState.Title` to match the surrounding heading levels:

```tsx
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:

```tsx
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:

```tsx
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`:

```tsx
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>
  );
}
```


#### Props

**EmptyState props**

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| align | "center" \| "left" \| "right" | 'center' | Content alignment. `center` stacks the content in a centered column, `left`/`right` place the indicator on the side with the content next to it. `left` and `right` are mirrored in RTL |
| children | React.ReactNode | - | `EmptyState` compound components, rendered after the shorthand props content. `EmptyState.Indicator` is always rendered first, outside of the body; if `icon` is set, it is rendered instead of the `EmptyState.Indicator` child |
| color | MantineColor | theme.primaryColor | Key of `theme.colors` or any valid CSS color, used by `filled` and `light` variants |
| description | React.ReactNode | - | Description content, rendered inside `EmptyState.Description` |
| icon | React.ReactNode | - | Icon or illustration, rendered inside `EmptyState.Indicator` |
| size | MantineSize | 'md' | Controls indicator size, gap between elements and font sizes of title and description |
| title | React.ReactNode | - | Title content, rendered inside `EmptyState.Title` |
| withIndicatorBackground | boolean | false | If set, a neutral circular background is displayed behind the indicator. Setting `variant` always displays a colored background regardless of this prop |

**EmptyState.Indicator props**

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| children | React.ReactNode | - | Icon or illustration displayed inside the indicator. The indicator is decorative and has `aria-hidden` set by default |

**EmptyState.Title props**

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| children | React.ReactNode | - | Title content |
| order | 2 \| 1 \| 3 \| 4 \| 5 \| 6 | - | Heading order, renders the title as `h1`–`h6` element. By default, the title is rendered as a `div` without semantic heading level |

**EmptyState.Description props**

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| children | React.ReactNode | - | Description content |

**EmptyState.Actions props**

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| children | React.ReactNode | - | Action buttons or controls |


#### Styles API

EmptyState component supports Styles API. With Styles API, you can customize styles of any inner element. Follow the documentation to learn how to use CSS modules, CSS variables and inline styles to get full control over component styles.

**EmptyState selectors**

| Selector | Static selector | Description |
|----------|----------------|-------------|
| root | .mantine-EmptyState-root | Root element |
| body | .mantine-EmptyState-body | Wrapper around `title`, `description` and `actions` |
| indicator | .mantine-EmptyState-indicator | Wrapper around the icon or illustration |
| title | .mantine-EmptyState-title | Title element |
| description | .mantine-EmptyState-description | Description element |
| actions | .mantine-EmptyState-actions | Wrapper around action buttons |

**EmptyState CSS variables**

| Selector | Variable | Description |
|----------|----------|-------------|
| root | --empty-state-indicator-size | Controls indicator icon size |
| root | --empty-state-gap | Controls gap between elements |
| root | --empty-state-title-fz | Controls title `font-size` |
| root | --empty-state-description-fz | Controls description `font-size` |
| root | --empty-state-indicator-color | Controls indicator color of `filled` and `light` variants |

**EmptyState data attributes**

| Selector | Attribute | Condition | Value |
|----------|-----------|-----------|-------|
| root | data-align | - | Value of `align` prop |
| root | data-variant | - | Value of `variant` prop |
| indicator | data-with-background | `withIndicatorBackground` prop is set or `variant` is set | - |
