Skip to content
Slotted

Result State

Stands in for content that is not there, such as an empty list, a search with no matches, a failed request or a missing page, and says what to do next.

No purchase orders yet

Create the first order to start tracking what you buy from suppliers.

Installation

The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.

bash
pnpm add @slotted/react @slotted/theme @slotted/themes
tsx
import { ResultState, ResultStateActions, ResultStateContent,  ResultStateDefaultsProvider, ResultStateDescription,  ResultStateFooter, ResultStateTitle } from '@slotted/react';

Result state, alert or inline message

A result state replaces the content it is about: a list with no rows, a panel that failed to load, a route that does not exist. Use it when the region has nothing else to show. An Alert sits beside content that is still on the page and frames a notice about it. An InlineMessage is one line under one control. A Skeleton fills the region while the request is pending, and the result state takes its place once the request returns nothing or fails; the two never share a region.

The region is a section named by its title. The title and the description sit in the content part, the only part that announces. The buttons sit in the actions part and the documentation link in the footer part, both outside the content part.

Statuses

status names the situation: empty, no-results, not-found, error, forbidden, offline or success. The value is written on the root as data-status and paints nothing, so the title and the description carry the meaning. Say what happened and what the reader can do about it. The default is empty.

empty
No shipments yet

Shipments appear here once a carrier collects an order.

no-results
No orders match this search

Check the spelling or search by order number.

not-found
Order SO-10492 does not exist

It may have been merged into another order.

error
Orders did not load

The orders service did not respond. Try again in a moment.

forbidden
Payroll reports are restricted

Only members of Finance can open them. Ask an administrator for access.

offline
You are offline

Changes are kept on this device and sync when the connection returns.

success
Refund issued

The customer receives 84.20 USD within 5 business days.

Reach

reach sets the scope of the message. inline is one row for a table cell or a toolbar, with the actions on the same line and no illustration. section is a panel inside a card or a page. page is a whole route and sets the title in the 3xl step of the type scale. The default is section.

inline
No rows match the filter
section
No open invoices

Invoices appear here when an order ships and stay until they are paid.

page
Page not found

The page you opened does not exist or has moved.

Alignment

align="center" centers the region and suits a panel or a route. align="start" reads from the inline edge and suits a screen of dense tables, where a centered column interrupts the rows. The default is center.

center
No saved reports

Save a report to run it again in one click.

start
No saved reports

Save a report to run it again in one click.

Your own artwork

The media part holds a glyph or an illustration of your own. In React pass it as media; in Angular project an element carrying slResultStateMedia. The part is hidden from assistive technology, so the title and the description must say what the picture says. The part keeps the height the reach gives it, so artwork that loads late does not move the title.

You are offline

Scans are saved on this scanner and upload when the connection returns.

Illustrations

illustration draws a neutral picture around the glyph in the media part: tile frames the glyph, stack leans three layers behind it and cards shows a thumbnail beside two lines, like a row. tile and stack draw nothing without a glyph, cards draws its lines with or without one, and inline reach draws none of them. The drawings take no tone.

tile
No alerts configured

Alerts tell you when stock runs low.

stack
Inbox is clear

No supplier messages are waiting.

cards
No documents attached

Attach packing slips or customs forms.

cards, no glyph
No rows to show

Import a file to fill this table.

The actions part holds the controls that get the reader out of the situation. Give a failed request the retry first and an alternative second. The controls are your own Buttons, so they keep every button state. They stack below a container width of 20rem. The footer part holds the line under the actions, such as a link to documentation that is not a call to action.

Carrier rates did not load

The rate service timed out, so shipping costs are not shown. Your cart is unchanged.

Retrying a request

Set loading on the retry button while the request is in flight, and keep the region on the page. The region changes its status and its text in place, so the content part, which already exists, announces the new message. Press the button: the retry takes 1.5 seconds.

Carrier rates did not load

The rate service timed out. Your cart is unchanged.

A search that matches nothing is no-results, and its action clears the search. The region replaces the list while the query matches nothing and the list returns when the query matches again. Press the button to clear the query.

What a reader hears

live sets whether the text announces itself. polite, the default, writes role="status" on the content part, because the region is the outcome of an operation. assertive writes role="alert" for a failure the reader has to hear now. off writes no role, for a screen that already owns a live region around this one. The root is never a live region and never moves focus: it carries tabindex="-1" so your code can send focus to it.

polite: role status
No orders match this search

Check the spelling or search by order number.

assertive: role alert
Payment was declined

Use another card to complete the order.

off: no role
No drafts

A live region on this screen announces changes.

Title as a heading

The title is a div by default, because a heading enters the document outline and only the page knows whether this message belongs there. A full page for a missing route does: render the title as the page’s h1. In React pass render to ResultStateTitle; in Angular write slResultStateTitle on an h1. A region inside one card of a grid keeps the div.

Order not found

Nothing exists at /orders/SO-10492-REV3. The order may have been deleted or merged.

Defaults

A defaults provider sets status, reach, align, live and illustration once for every result state under it: ResultStateDefaultsProvider in React and provideResultStateDefaults in Angular. A region that sets a value of its own keeps it. A screen of tables sets reach="inline" and align="start" once.

No late shipments

Every carrier picked up on time this week.

No returns in this period

Widen the date range to see earlier returns.

Inventory counts did not load

This region sets its own reach and alignment.

Accessibility

  • 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.

API

ResultState

Props

status'empty' | 'no-results' | 'not-found' | 'error' | 'forbidden' | 'offline' | 'success'Default empty
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'Default section
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'Default center
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'Default polite
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'Default none
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.
mediaReactNode
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.

Composition

render(props) => ReactNode
On every partSubstitutes 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.
refRef<HTMLElement>
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.
idstring
On ResultStateTitleAn 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 }
On a subtreeSets all five once for every region under it; an explicit prop on one region still wins.
childrenReactNode
On ResultStateContentThe 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, Cardcomposition
On around ResultStateThe measure belongs to Container and the frame to Card. Result state caps no width and draws no box.

Parts

PartElementRequiredPurpose
rootsectionYesThe region. Carries data-ui="result-state", the data-status, data-reach, data-align, data-illustration and data-live attributes, and tabindex="-1". A section named by its own title is a region landmark a reader can jump to; unnamed it is a plain grouping element that costs nothing.
mediadivNoThe page’s glyph or its own artwork, hidden from assistive technology. With illustration set, result state draws a tile, a stack or a stack of cards around the glyph here. It keeps the height the reach gives it, so artwork that has not loaded moves nothing when it arrives. Empty it is withdrawn by the stylesheet, except under cards, which draws its lines without a glyph.
contentdivYesThe title and the description, and nothing else. This is the live region: role="status" or role="alert" is written here, so the buttons beside it are outside what a reader hears.
titlediv, or the element render returnsNoThe message’s name, and the region’s: the root points aria-labelledby at it. A div by default, because a heading belongs in the document outline and only the page knows whether this message does. An id the page writes is kept, and the root points at that one instead.
descriptionp, or the element render returnsNoWhat to do next. It breaks a string no language can break — a resource id, a host name without a hyphen — rather than overflowing, and removes nothing from the DOM to do it.
actionsdivNoThe controls that get the reader out of the situation, outside the live region. They stack below a container width of 20rem, and at inline reach they sit on the message’s own first line.
footerdivNoThe line under the actions: the documentation link that is not a call to action. Set one step down and in the muted role, because it is neither of the buttons above it.

Theming

Each token is a CSS custom property: set it in a theme, or on any element to retune every result state inside it.

Result State tokens

TokenDefault
--slotted-result-state-actions-block-gapvar(--slotted-space-8, 1.5rem)
--slotted-result-state-actions-gapvar(--slotted-action-gap, 8px)
--slotted-result-state-column-gapvar(--slotted-space-4, 0.5rem)
--slotted-result-state-description-font-sizevar(--slotted-font-size-md, 0.875rem)
--slotted-result-state-font-familyvar(--slotted-font-family-sans, sans-serif)
--slotted-result-state-media—
--slotted-result-state-media-sizevar(--slotted-control-height-md, 34px)
--slotted-result-state-padding-blockvar(--slotted-space-9, 2rem)
--slotted-result-state-padding-inlinevar(--slotted-space-6, 1rem)
--slotted-result-state-row-gapvar(--slotted-space-6, 1rem)
--slotted-result-state-text-gapvar(--slotted-space-4, 0.5rem)
--slotted-result-state-title-font-familyvar( --slotted-font-family-heading, var(--slotted-font-family-sans, ui-sans-serif, system-ui, sans-serif) )
--slotted-result-state-title-font-sizevar(--slotted-font-size-xl, 1.125rem)
--slotted-result-state-title-font-weightvar(--slotted-font-weight-semibold, 600)
--slotted-result-state-title-letter-spacing-0.01em

Theme tokens it reads

TokenDefault
--slotted-action-gapcomfortable 8px · compact 6px · dense 4px
--slotted-border-strongSet per scheme by the theme
--slotted-border-subtleSet per scheme by the theme
--slotted-border-width-thin1px
--slotted-control-height-lgcomfortable 38px · compact 32px · dense 30px
--slotted-control-height-mdcomfortable 34px · compact 28px · dense 26px
--slotted-control-height-smcomfortable 30px · compact 26px · dense 24px
--slotted-control-icon-size-lgcomfortable 18px · compact 16px · dense 14px
--slotted-control-icon-size-mdcomfortable 16px · compact 14px · dense 13px
--slotted-duration-long320ms
--slotted-duration-medium200ms
--slotted-duration-short120ms
--slotted-easing-entercubic-bezier(0.05, 0.7, 0.1, 1)
--slotted-easing-exitcubic-bezier(0.3, 0, 0.8, 0.15)
--slotted-focus-ring-colorSet per scheme by the theme
--slotted-focus-ring-offsetvar(--slotted-border-width-thick)
--slotted-focus-ring-widthvar(--slotted-border-width-thick)
--slotted-font-family-headingvar(--slotted-font-family-sans)
--slotted-font-family-sans'Geist Variable', ui-sans-serif, system-ui, sans-serif
--slotted-font-size-3xl1.5rem
--slotted-font-size-lg1rem
--slotted-font-size-md0.875rem
--slotted-font-size-sm0.8125rem
--slotted-font-size-xl1.125rem
--slotted-font-size-xs0.75rem
--slotted-font-weight-semibold600
--slotted-line-height-3xl1.3
--slotted-line-height-md1.5
--slotted-line-height-sm1.45
--slotted-line-height-xl1.45
--slotted-radius-lg8px
--slotted-radius-sm4px
--slotted-shadow-smSet per scheme by the theme
--slotted-shadow-xsSet per scheme by the theme
--slotted-space-113rem
--slotted-space-124rem
--slotted-space-20.25rem
--slotted-space-30.375rem
--slotted-space-40.5rem
--slotted-space-50.75rem
--slotted-space-61rem
--slotted-space-81.5rem
--slotted-space-92rem
--slotted-surface-raisedSet per scheme by the theme
--slotted-surface-sunkenSet per scheme by the theme
--slotted-textSet per scheme by the theme
--slotted-text-mutedSet per scheme by the theme