# Empty state

Source: https://ecosphere.dev/docs/data/empty-state (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

Icon, display headline, one line of help, one primary.

`import { EcoEmptyState } from "vue-ecosphere"`

## First run

Empty because nothing exists yet. Never “No data available”, which tells the user nothing they cannot already see.

Vue (vue-ecosphere):

```vue
<EcoEmptyState
  icon="inbox-line"
  text="This list fills in as records arrive. You can also add the first one by hand."
  action-label="Add a record"
  action-icon="add-line"
  @action="addRecord"
>
  <template #title>Nothing here <em>yet</em>.</template>
</EcoEmptyState>
```

React (react-ecosphere):

```tsx
<EcoEmptyState
  icon="inbox-line"
  title={<>Nothing here <em>yet</em>.</>}
  text="This list fills in as records arrive. You can also add the first one by hand."
  actionLabel="Add a record"
  actionIcon="add-line"
  onAction={addRecord}
/>
```

## No results

Empty because a filter emptied it: different copy, and a different button.

Vue (vue-ecosphere):

```vue
<EcoEmptyState
  icon="search-line"
  text="Three filters are active. Clearing the narrowest one usually brings results back."
  action-label="Clear filters"
  action-icon="refresh-line"
  @action="clearFilters"
>
  <template #title>No matches for <em>that filter</em>.</template>
</EcoEmptyState>
```

React (react-ecosphere):

```tsx
<EcoEmptyState
  icon="search-line"
  title={<>No matches for <em>that filter</em>.</>}
  text="Three filters are active. Clearing the narrowest one usually brings results back."
  actionLabel="Clear filters"
  actionIcon="refresh-line"
  onAction={clearFilters}
/>
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` | `string` | "inbox-line" | RemixIcon in the round well. |
| `title` | `string` | — | Headline. Use the title slot for the one em that carries the accent. |
| `text` | `string` | — | The help line: what will fill the space, or what to change. The default slot overrides it. |
| `actionLabel` | `string` | — | Label of the one primary button. The action slot replaces the button. |
| `actionIcon` | `string` | — | Leading icon on the button. |
| `as` | `"h2" \| "h3" \| "h4"` | "h2" | Heading level of the headline. |
| `@action` | `(e: MouseEvent)` | — | The primary button was pressed. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` | `string` | "inbox-line" | RemixIcon in the round well. |
| `title` | `ReactNode` | — | Headline: text, or a node for the one em that carries the accent. |
| `text` | `string` | — | The help line: what will fill the space, or what to change. Children override it. |
| `actionLabel` | `string` | — | Label of the one primary button. The action prop (a ReactNode) replaces the button. |
| `actionIcon` | `string` | — | Leading icon on the button. |
| `as` | `"h2" \| "h3" \| "h4"` | "h2" | Heading level of the headline. |
| `onAction` | `(e: MouseEvent)` | — | The primary button was pressed. |
