Feedback

ErrorState

Centred error placeholder with a disc, title, description, progress line, retry, secondary action and details disclosure for a failed load, or a neutral not-found state.

import { ErrorState } from '@lostgradient/cinder';
feedbackerror
01

Overview

Reference usage

Placeholder layout for a region whose data failed to load. The default layout is the centred page state: a 48px disc, the title (16px semibold), a sentence of at most 380px, an optional progress line, the actions, and a collapsed details disclosure. A failure is announced as an alert and never looks like an empty result; a neutral tone covers a thing that doesn't exist, where nothing failed.

The words follow one rule on every page: say what failed in plain words, whether it was the person, and the next action. Use contractions, sentence case and no exclamation marks. Fault codes go in detail, behind the "Show the error details" disclosure. Show an error where it happened (a field, a row, a step); use a full-page error state only when the page has nothing to show, and never beside a banner for the same failure.

Usage

svelte
<script lang="ts">
  import { ErrorState } from '@lostgradient/cinder';
</script>

<ErrorState
  title="Couldn't load runs"
  description="The server answered with an error (500). Nothing you did caused it."
  detail="HTTP 500 from /api/runs"
  onRetry={() => console.log('retry')}
/>

The retry button is the primary action, with a refresh glyph, and the only primary on the page. When the primary action is not a retry (a "New chat" button on a not-found page), give it its own words with retryLabel and its own glyph with the retryIcon snippet. Add a second action with the secondaryAction snippet, and a line of progress with retryStatus (it is not a live region, so a countdown never announces itself every second):

svelte
<script lang="ts">
  import { Button, ErrorState } from '@lostgradient/cinder';
</script>

<ErrorState
  title="Couldn't load runs"
  description="Interborough didn't answer. Your runs are safe; they're stored on this machine."
  retryStatus="Retrying in 8 s (attempt 3 of 8)"
  retryLabel="Retry now"
  onRetry={() => console.log('retry')}
>
  {#snippet secondaryAction()}
    <Button variant="secondary" label="Open Health" />
  {/snippet}
</ErrorState>

The neutral tone is for a state where nothing failed, such as a missing page: a neutral disc with a search glyph, a plain group instead of an alert, and no retry:

svelte
<script lang="ts">
  import { Button, ErrorState } from '@lostgradient/cinder';
</script>

<ErrorState
  tone="neutral"
  title="This run doesn't exist"
  description="It may have been deleted. The address might also be mistyped."
>
  {#snippet secondaryAction()}
    <Button variant="secondary" label="Back to Runs" />
  {/snippet}
</ErrorState>

Flat — no disc and no padding of its own, for a card or tab whose container already pads it. The content is start-aligned and the error is still announced as an alert:

svelte
<script lang="ts">
  import { ErrorState } from '@lostgradient/cinder';
</script>

<ErrorState
  variant="flat"
  title="Couldn't load runs"
  description="The server did not respond in time."
  onRetry={() => console.log('retry')}
/>

Row — a small warning glyph, the title and description read as one sentence, and a secondary "Try again" at the end of the line, for one card that failed to load while the others stay live. The retry drops under the words on a phone:

svelte
<script lang="ts">
  import { ErrorState } from '@lostgradient/cinder';
</script>

<ErrorState
  variant="row"
  headingLevel={3}
  title="Couldn’t load system problems."
  description="The rest of Home is live."
  onRetry={() => console.log('retry')}
/>
Live preview

Compact, in a list pane

02

When to use

Use when
  • Replacing a primary content region after its query or request failed, so the failure never looks like an empty result.
  • Offering the user a retry for a region that can be reloaded, with the retry as the only primary action on the page.
  • Telling a person that the thing they asked for doesn't exist, using the neutral tone.
Avoid when
  • Communicating that a region has no data — use empty-state instead.
  • Reporting the result of a just-completed action — use alert or toast-region.
03

Examples

Compact, in a list pane

size="compact" shrinks the disc, quiets the type and makes the retry a small secondary button, so a list pane that failed to load says so without claiming the page’s one primary action.

Not found

The neutral tone for a thing that doesn’t exist: nothing failed, so it is not announced as an alert. A page that offers a way forward gives the primary button its own label and glyph with retryLabel and retryIcon, then a secondary action beside it.

Full-page error under a header and tabs

When nothing can show, the error state takes the height left under the heading and tabs, centred, with the header’s + secondary and inert (focusable, with its reason as the description) and Try again the only primary. It is never drawn with a banner.

Retry status and a second action

The retry is the page’s only primary action; a secondary action, a progress line and the fault code behind a disclosure sit with it.

With retry

A failed query with a fault code and a retry button.

Without retry

Omit onRetry when the failure cannot be retried from this region.

04

Props

Props for error-state
Name
Type
Default
Description
title required text Primary heading text rendered as a heading element at the configured headingLevel.
description required text Secondary descriptive text rendered as a paragraph below the title.
detail text Optional technical detail, such as a fault code. It sits behind a disclosure labelled detailsLabel, so the plain-words description stays the first thing a person reads.
detailsLabel text 'Show the error details' Label of the disclosure that holds detail.
retryStatus text A line of progress under the description, such as "Retrying in 8 s (attempt 3 of 8)". It renders in tabular figures and is not a live region, so a countdown never announces itself every second.
tone 'danger' | 'neutral' 'danger' What kind of problem this reports. 'danger' is a failure and is announced as an alert; 'neutral' is a state where nothing failed, such as a missing page, and is a plain group.
onRetry () => void Called when the retry button is activated. The retry button renders only when this is given. It is the page's primary action.
retryLabel text 'Try again' Label of the retry button.
retryVariant 'primary' | 'secondary' 'primary' How prominent the retry button is. 'primary' suits a full-page failure, where retrying is the one thing to do. 'secondary' suits a section of a page that has other controls, such as a tab's body under a tab bar, so the retry does not outrank them.
retryIcon snippet Replaces the refresh glyph on the primary button. Use it when the primary action is not a retry, such as a "New chat" button with a pencil on a not-found page. Decorative.
secondaryAction snippet A second action rendered after the retry button, such as an "Open Health" link or a "Back to chats" button. Give it the secondary or ghost button variant so the retry button stays the only primary on the page.
icon snippet Replaces the glyph in the disc. The default is a warning triangle for the 'danger' tone and a magnifying glass for 'neutral'. Decorative, so it is hidden from assistive technology.
headingLevel 123456 2 Heading level for the title element.
variant 'default' | 'flat' | 'row' 'default' Layout. 'default' is the centred page layout: a 48px tinted disc with a glyph, the title, the description, the progress line, then the actions, centred in the region it fills. 'flat' renders the same text as a start-aligned block with no disc and no padding of its own, for a card or tab whose container already pads it. 'row' lays a small warning glyph, the title and description as one sentence, and a secondary retry button (no refresh glyph unless retryIcon is given) on one line, for the failure of one card among others that are live; the retry drops under the words on a phone.
size 'default' | 'compact' 'default' Scale of the centred layout. 'compact' tightens the padding, shrinks the disc to 40px and tints it neutral, sets the title in the base size, and makes the retry a small secondary button with no refresh glyph, so the state fits a list pane that failed to load without claiming the page's one primary action. It has no effect on the 'flat' and 'row' variants.
bordered boolean false Draws the state inside a bordered, rounded box, for a list or page body that has no container of its own. Leave it off when a card or panel already surrounds the state. It applies to the centred layout; the 'flat' variant has no box.