# EmptyState

A named section for an empty successful result. It shows a title with an optional description, decorative icon and caller-supplied action. Compose it inside an existing container.

**Dependencies:** npm: 0 direct, 1 total; registry: 2 direct, 2 total.

Native: iOS stable, Android stable.

## Usage

### When to use

- Explain why a successful view has no content yet and offer its first action.
- Explain that filters returned no matches and offer a way to adjust them.

### When not to use

- Content is still loading. Use Skeleton or Spinner.
- An operation failed. Use Alert.
- A table has no rows. Use Table with its empty content.

### Native

**Default**

```text
WerewolfEmptyState(title: AnyView(Text("No projects yet")))
```

```text
WerewolfEmptyState { Text("No projects yet") }
```

**With description and action**

```text
WerewolfEmptyState(action: AnyView(Button("New project") { }), description: AnyView(Text("Create one to get started.")), title: AnyView(Text("No projects yet")))
```

```text
WerewolfEmptyState(action = { Button(onClick = {}) { Text("New project") } }, description = { Text("Create one to get started.") }) { Text("No projects yet") }
```

## Examples

### First use

```tsx
<EmptyState title="No projects yet" description="Create a project to keep your ideas and files together." icon={<IconInbox size={20} />} action={<Button>Create project</Button>} />
```

### Filtered results

```tsx
<EmptyState title="No matching projects" description="Try another search or clear the filters to see all projects." icon={<IconSearch size={20} />} action={<Link href="#all-projects">View all projects</Link>} />
```

## Do and don't

### Do

- Explain why there is no content and give a useful next step.
- Use a first-use message before any content exists and a different message when filters hide content.
- Compose inside an existing page section or Card.

### Don't

- Do not use an empty state for loading or errors.
- Do not add a second card border around the component.
- Do not announce static empty sections as live regions.

## Props

| Name | Type | Values | Default | Description |
| --- | --- | --- | --- | --- |
| `title` (required) | `node` |  |  | Short heading naming the empty result. |
| `description` | `node` |  |  | Explanation or next step for the empty result. |
| `icon` | `node` |  |  | Decorative icon supplied by the caller. |
| `action` | `node` |  |  | Caller-supplied action that helps the user proceed. |

## Anatomy

| Part | Description |
| --- | --- |
| `root` | Centered named section with token spacing and no card border. |
| `title` | Heading that names the section by default. |
| `description` | Optional secondary text explaining why the result is empty. |
| `icon` | Optional decorative icon in the secondary icon color. |
| `actions` | Caller-supplied action such as Button or Link. |

## Accessibility

Role: `region`

- The title names the section unless aria-label or aria-labelledby provides a different name.
- No live region is added by default. A caller can set role="status" when results change.
- The icon is decorative. Title and description explain the empty result.

## Install

```bash
npx werewolf-ui add empty-state
```

Run `npx werewolf-ui init` once in your app before adding components. Init sets up tokens, their CSS import and agent rules. Add installs this component and its dependencies while preserving your theme. See [Installation](https://www.werewolf-ui.dev/docs/installation.md) for requirements and the alternative registry setup.

```bash
npx werewolf-ui add empty-state --platform ios
npx werewolf-ui add empty-state --platform android
```

For iOS and Android, run `npx werewolf-ui init --platform ios` or `npx werewolf-ui init --platform android` once, then add with `--platform`. See [Installation](https://www.werewolf-ui.dev/docs/installation.md).
