# Empty state

- Entry point: `@koobiq/components/empty-state`
- NgModule: `KbqEmptyStateModule`
- API: https://koobiq.io/api/empty-state.md
- Component tokens: https://koobiq.io/tokens/empty-state.md
- Page: https://koobiq.io/en/components/empty-state/overview

A placeholder component for empty states or error messages. The border is not part of the component; it is shown only for illustration purposes.

[**Example: Empty-state default** (`empty-state-overview`)](https://koobiq.io/examples/empty-state-overview.md)

## Size

For full-screen placeholders, a block with larger-sized elements can be used.

[**Example: Empty-state big** (`empty-state-big`)](https://koobiq.io/examples/empty-state-big.md)

## Size - variations

The component size is set using the `size` attribute.

[**Example: Empty-state size** (`empty-state-size`)](https://koobiq.io/examples/empty-state-size.md)

## Align

Content can be aligned to the center or to the top. The `alignTop` attribute selects the top.

[**Example: Empty-state align** (`empty-state-align`)](https://koobiq.io/examples/empty-state-align.md)

The component has no height of its own: it grows as a flex item, and in any other container it is exactly as tall as its content, which leaves both alignments looking the same. Give the component or its container a height — the examples here use `min-height` — for the alignment to have an effect.

## Error

The Empty State component can be used to display an error message. It is switched on with the `errorColor` attribute: the title and the text turn red, and an icon in the illustration slot is tinted with them.

[**Example: Empty-state error** (`empty-state-error`)](https://koobiq.io/examples/empty-state-error.md)

## Content

### Illustration

The illustration size can be changed. A large illustration is suitable for full-screen placeholders. If a placeholder is needed for just a specific block, the illustration can be made compact or omitted entirely.

[**Example: Empty-state content** (`empty-state-content`)](https://koobiq.io/examples/empty-state-content.md)

In a center-aligned component with an illustration, an additional bottom offset is added, which raises the composition to provide optical compensation.

### Icon

An icon can be used as the illustration.

[**Example: Empty-state icon** (`empty-state-icon`)](https://koobiq.io/examples/empty-state-icon.md)

### Title

[**Example: Empty-state title** (`empty-state-title`)](https://koobiq.io/examples/empty-state-title.md)

### Actions

One or more actions can be placed below the text: buttons, links, and pseudo-links.

[**Example: Empty-state actions** (`empty-state-actions`)](https://koobiq.io/examples/empty-state-actions.md)

[**Example: Empty-state actions more** (`empty-state-actions2`)](https://koobiq.io/examples/empty-state-actions2.md)

### Text only

[**Example: Empty-state text only** (`empty-state-text-only`)](https://koobiq.io/examples/empty-state-text-only.md)

### Conditional slots

When a slot is rendered conditionally, the condition has to be top level: the `@if` wraps the slot element itself.

```html
@if (failed()) {
<i kbq-empty-state-icon kbq-icon-item="kbq-triangle-exclamation_16"></i>
}
```

Blocks nested in one another, and several elements in one block, do not work — that is how content projection behaves in Angular. Such content never reaches the DOM, with no error and no warning.

When there are several variants, give each its own `@if` at the same level: `@if (hasIcon() && wrapped())` and `@if (hasIcon() && !wrapped())`.

## Accessibility

The title is rendered with heading typography — `subheading` at the normal size, `headline` at the big one — so write it as a real heading of the level the surrounding page calls for, `<h2 kbq-empty-state-title>`, rather than as a `div`. The component zeroes the browser's own heading margin, so the spacing stays the same whichever element is used.

An empty state is usually inserted into a page that has already been read: after a search returns nothing, or after a request fails. Add `role="status"` on `<kbq-empty-state>` so that assistive technology announces it, or `role="alert"` for the error variant, which is announced more insistently.

The component adds no `role` of its own, because an empty state that is part of the page from the start — an initially empty list, say — has nothing to announce.
