<!-- index: /slotted/llms.txt -->
# result-state

`data-ui="result-state"` · Empty, no-results, error or success state.

## Import

```tsx
import {
  ResultState,
  ResultStateActions,
  ResultStateContent,
  ResultStateDefaultsProvider,
  ResultStateDescription,
  ResultStateFooter,
  ResultStateTitle,
} from '@slotted/react';
```

## Minimal example

Example

```tsx
import { Button } from '@slotted/react/button';
import {
  ResultState,
  ResultStateActions,
  ResultStateContent,
  ResultStateDescription,
  ResultStateTitle,
} from '@slotted/react/result-state';

export default function ResultStateBasic() {
  return (
    <ResultState>
      <ResultStateContent>
        <ResultStateTitle>No purchase orders yet</ResultStateTitle>
        <ResultStateDescription>
          Create the first order to start tracking what you buy from suppliers.
        </ResultStateDescription>
      </ResultStateContent>
      <ResultStateActions>
        <Button>Create purchase order</Button>
      </ResultStateActions>
    </ResultState>
  );
}
```

## Anatomy

| Part | Element | Required |
| --- | --- | --- |
| `root` | section | yes |
| `media` | div | no |
| `content` | div | yes |
| `title` | div, or the element render returns | no |
| `description` | p, or the element render returns | no |
| `actions` | div | no |
| `footer` | div | no |

## Props

| Name | Type | Default | Applies to | Description |
| --- | --- | --- | --- | --- |
| `status` | `'empty' \| 'no-results' \| 'not-found' \| 'error' \| 'forbidden' \| 'offline' \| 'success'` | empty | ResultState | What the region is reporting, written on the root as data-status for a page to key its own artwork on. Result state paints nothing for it: what happened is in the title and the description. |
| `reach` | `'inline' \| 'section' \| 'page'` | section | ResultState | The scope the message applies to. inline is a row for a table cell and draws no illustration; page takes the 3xl step of the type scale and draws the illustration half again as large. |
| `align` | `'center' \| 'start'` | center | ResultState | Whether the region reads centered or from the inline edge. start is for a data-dense screen, where a centered column reads as an interruption. |
| `live` | `'off' \| 'polite' \| 'assertive'` | polite | ResultState | Whether the text announces itself. polite writes role="status" on the content part and assertive writes role="alert"; both imply aria-live and aria-atomic, and neither is written on the box. |
| `illustration` | `'none' \| 'tile' \| 'stack' \| 'cards'` | none | ResultState | The drawing result state makes around the glyph in media, in the neutral surface and border roles and never in a tone. tile and stack frame a glyph and draw nothing without one; cards draws its lines with or without it; none draws nothing of its own. |
| `media` | `ReactNode` | — | ResultState | The glyph an illustration is drawn around, or artwork the page supplies under illustration="none", projected into the box result state draws so it keeps the height the reach gives it. Angular projects an element carrying slResultStateMedia instead. |
| `render` | `(props) => ReactNode` | — | every part | Substitutes the rendered element of ResultState, ResultStateContent, ResultStateTitle, ResultStateDescription, ResultStateActions or ResultStateFooter, and hands it every data attribute. A title rendered as a heading is how a page puts the region in its outline. |
| `ref` | `Ref<HTMLElement>` | — | ResultState | Reaches the section, which carries tabindex="-1" so focus() works. It is the whole imperative surface: result state never moves focus by itself, because moving it unprompted is a change of context nobody asked for. |
| `id` | `string` | — | ResultStateTitle | An identifier you write is kept, and the root points aria-labelledby at that one rather than at its own. |
| `ResultStateDefaultsProvider` | `{ status, reach, align, live, illustration }` | — | a subtree | Sets all five once for every region under it; an explicit prop on one region still wins. |
| `children` | `ReactNode` | — | ResultStateContent | The title and the description. Anything else placed here joins the live region, which is why the actions and the footer are parts of their own. |
| `Container, Card` | `composition` | — | around ResultState | The measure belongs to Container and the frame to Card. Result state caps no width and draws no box. |

## Axes and defaults

| Axis | Values | Default |
| --- | --- | --- |
| `status` | `empty`, `no-results`, `not-found`, `error`, `forbidden`, `offline`, `success` | `empty` |
| `reach` | `inline`, `section`, `page` | `section` |
| `align` | `center`, `start` | `center` |
| `illustration` | `none`, `tile`, `stack`, `cards` | `none` |
| `live` | `off`, `polite`, `assertive` | `polite` |

## Rules

- The Authoring Practices Guide has no pattern for empty, error or result states. The nearest guidance is the region landmark practice, which states that “a region landmark must have a label”. The root is a section and aria-labelledby is written only once a title exists, so a region without a title is a plain grouping element rather than a landmark with no name.
- The box is a landmark, not a live region. The MDN reference for the alert role states that the role “should only be used for text content, not interactive elements such as links or buttons”, and a result state holds buttons. The content part is the live region and holds the title and the description alone; the media, the actions and the footer are its siblings.
- live defaults to polite, where Alert defaults to off. The Understanding document for WCAG 2.2 SC 4.1.3 gives “No results returned” as an example of a status message. An alert may be a standing notice that was on the page before it loaded; a result is always the outcome of an operation.
- Status is never carried by color, because result state paints no color for it: what happened is in the title and the description, which forced colors leave legible. The illustrations keep the theme’s system-color mapping under forced colors, so a stack is still three layers and not three outlines laid over one another.
- The media box is hidden from assistive technology, with the glyph, the drawing made around it and any artwork you supply. The title and the description must say what the picture says. An illustration that adds information is not decorative, and what it adds belongs in the description.
- The root carries tabindex="-1" and is not in the tab sequence. After your code empties a table, it can send the reader to the message through the ref. Result state never moves focus by itself, because moving focus unprompted is a change of context nobody asked for.
- Result state holds no mutable value, so it emits no events and has no event table. Which status a region is in is a fact about your own data: a region that decided it would be deciding whether the request failed.
- A region that announces arrives: its words fade in and its drawing assembles, on the entering curve, and a hidden region fades out on the leaving curve. Under reduced motion the drawing arrives assembled. The focus indicator is not animated, because a focus indicator that fades in is one that is not there yet.

## Tokens

`--slotted-action-gap`, `--slotted-border-strong`, `--slotted-border-subtle`, `--slotted-border-width-thin`, `--slotted-control-height-lg`, `--slotted-control-height-md`, `--slotted-control-height-sm`, `--slotted-control-icon-size-lg`, `--slotted-control-icon-size-md`, `--slotted-duration-long`, `--slotted-duration-medium`, `--slotted-duration-short`, `--slotted-easing-enter`, `--slotted-easing-exit`, `--slotted-focus-ring-color`, `--slotted-focus-ring-offset`, `--slotted-focus-ring-width`, `--slotted-font-family-heading`, `--slotted-font-family-sans`, `--slotted-font-size-3xl`, `--slotted-font-size-lg`, `--slotted-font-size-md`, `--slotted-font-size-sm`, `--slotted-font-size-xl`, `--slotted-font-size-xs`, `--slotted-font-weight-semibold`, `--slotted-line-height-3xl`, `--slotted-line-height-md`, `--slotted-line-height-sm`, `--slotted-line-height-xl`, `--slotted-radius-lg`, `--slotted-radius-sm`, `--slotted-result-state-actions-block-gap`, `--slotted-result-state-actions-gap`, `--slotted-result-state-column-gap`, `--slotted-result-state-description-font-size`, `--slotted-result-state-font-family`, `--slotted-result-state-media`, `--slotted-result-state-media-size`, `--slotted-result-state-padding-block`, `--slotted-result-state-padding-inline`, `--slotted-result-state-row-gap`, `--slotted-result-state-text-gap`, `--slotted-result-state-title-font-family`, `--slotted-result-state-title-font-size`, `--slotted-result-state-title-font-weight`, `--slotted-result-state-title-letter-spacing`, `--slotted-shadow-sm`, `--slotted-shadow-xs`, `--slotted-space-11`, `--slotted-space-12`, `--slotted-space-2`, `--slotted-space-3`, `--slotted-space-4`, `--slotted-space-5`, `--slotted-space-6`, `--slotted-space-8`, `--slotted-space-9`, `--slotted-surface-raised`, `--slotted-surface-sunken`, `--slotted-text`, `--slotted-text-muted`

## Examples

See [result-state.examples.md](./result-state.examples.md).
