Skip to content

ErrorState

Stands in for content that failed to load.

import { ErrorState } from '@/design-system';

Examples

'use client';

import { useState } from 'react';
import { Button, ErrorState } from '@/design-system';

export default function ErrorStateBasic() {
  const [failed, setFailed] = useState(false);

  if (!failed) {
    return <Button onClick={() => setFailed(true)}>Simulate a failure</Button>;
  }
  return (
    <ErrorState
      title="We couldn’t load this data"
      action={
        <Button variant="secondary" onClick={() => setFailed(false)}>
          Try again
        </Button>
      }
    >
      Check your connection and try again.
    </ErrorState>
  );
}

How it works

  • It is wrapped in role="alert", so screen readers announce it when it appears.
  • A mark before the title means the error does not rely on colour. It uses --critical.

Props

ErrorState takes only these props.

ErrorState props
PropTypeDefaultDescription
titlestringrequiredA level-two heading.
childrenReactNode—What happened and what to do.
actionReactNode—Usually one button.
classNamestring—Extra classes, for spacing or width. Utility classes override the component’s own styles.

Tokens

Tokens
TokenDefaultSets
--state-title-size1remTitle text size
--state-radius--radius-controlCorner radius
--state-padding3.5rem 1.5remPadding