Error states
Tells people what happened, keeps their work and gives them a way forward.
Errors are part of normal use. A good error says what happened in plain words, says whose side it is on, keeps what the person has done and offers a next step. Errors use the destructive token, which in the Silkware theme is the brand crimson, and are always written out as well as coloured.
Anatomy
- Field with its message for a single field, and Alert for a message about a form or a section.
- Button for the way forward: Try again, Ask for access, Go to the home page.
- Skeleton and Spinner while a retry runs.
- Item for suggested destinations on a page that cannot be found.
- The Logo on full-page errors.
Field and form errors
Field errors appear on submit. A failure to save keeps everything the person entered, says the finance system did not answer, and offers Try again. The second attempt succeeds and shows a success badge with a check icon and the word Saved.
A failed section
One panel fails inside a working page. The figures above it stay, the panel explains what happened, and Try again retries only that panel. The first retry fails again with a more specific message, the second succeeds.
Choose a section error whenever the rest of the page is still useful.
Full-page errors
Use a full page only when the whole page cannot be shown.
Not found, with places to go instead:
No permission, with a request to the person who can grant access:
Something went wrong, with a reference and a retry:
Behaviour
- Scope. Show the error as close to its cause as possible: field, section, page.
- Keep the work. Never clear what the person entered.
- Retry. The retry button shows a pending state, and the message changes if it fails again.
- Focus. After a form error, focus goes to the first invalid field or the summary. On a full-page error the heading takes focus.
- Reference. Server errors show a short reference that support can look up.
- Responsive. One column, buttons wrap, nothing is clipped at 320px.
On a phone
The form error and the three full-page errors (error-states-01, -03, -04 and -05) put pointer-coarse:touch-controls on the page: the way forward is the one action on the screen. The failed-section block (error-states-02) stays as shipped, since its retry sits in a dense dashboard beside other compact controls. See Sizing.
Accessibility
- Alerts use the alert role, so they are announced when they appear.
- Field messages are tied to their fields and read when the field receives focus.
- Colour is never the only signal: every error has words, and invalid controls change their border.
- Every error page has a heading and at least one working link or button.
Content
- Say what happened, then what to do. Do not blame the person and do not show codes without words.
- Name the system when it helps: "The finance system did not answer."
- Say what is safe: "Nothing you entered was lost."
- Offer a way out: retry, go back, ask someone, contact support.
The quality system did not answer. The rest of the page is up to date.
Say what failed, what still works and what to try.
Don’t blame the person or show a bare code.
Install
pnpm dlx shadcn@latest add @silkware/error-states-01pnpm dlx shadcn@latest add @silkware/error-states-02pnpm dlx shadcn@latest add @silkware/error-states-03pnpm dlx shadcn@latest add @silkware/error-states-04pnpm dlx shadcn@latest add @silkware/error-states-05