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.
| Prop | Type | Default | Description |
|---|---|---|---|
title | string | required | A level-two heading. |
children | ReactNode | — | What happened and what to do. |
action | ReactNode | — | Usually one button. |
className | string | — | Extra classes, for spacing or width. Utility classes override the component’s own styles. |
Tokens
| Token | Default | Sets |
|---|---|---|
--state-title-size | 1rem | Title text size |
--state-radius | --radius-control | Corner radius |
--state-padding | 3.5rem 1.5rem | Padding |