Result
The outcome of something people did, or why a page cannot show.
import { Result } from '@halo-ds/react';
When to use it
Use Result after an action finishes, like a payment going through, or when a page cannot load, like a missing page or no access. Say what happened, what it means, and give the next step.
Do
- Say what happened in the title, like Payment sent.
- Say what it means or what to do next in one or two sentences.
- Give one clear way forward as the main button.
- Put details like a receipt in Content.
Don't
- Use it for small confirmations; use a Toast.
- Blame the person; say what to do instead.
- Show error codes alone; explain them in words.
- Leave a page without a way out.
Props
Result props
| Prop | Type | What it does | ||
|---|---|---|---|---|
status (required) | ResultStatus | What happened. Success, error, warning and information show an icon in a circle; the rest show an illustration. Ant Design's 404, 403 and 500 are not-found, no-access and server-error. Figma: Status. | ||
title (required) | ReactNode | Figma: Title. | ||
description | ReactNode | One or two sentences: what it means and what to do next. Figma: Description. | ||
actions | ReactNode | Buttons, like Back to overview. The first should be the way forward. Figma: Actions. | ||
children | ReactNode | Details under the text, like a receipt or a list of what failed. Figma: Content. | ||
icon | ReactNode | Replaces the status icon or illustration. | ||
size | `"sm" \ | "md" \ | undefined` | md for a full page, sm inside a card or a dialog. Figma: Size. |
classNames | `Partial<Record<ResultPart, string>> \ | undefined` | Extra class names for the parts inside the component, by part name, like { header: 'my-header' }. | |
styles | `Partial<Record<ResultPart, CSSProperties>> \ | undefined` | Inline styles for the parts inside the component, by part name, like { footer: { gap: 4 } }. |
It also takes the usual HTML attributes for its element.
Examples
Overview
import { Button, Result } from '@halo-ds/react';
export default function Example() {
return (
<Result
status="success"
title="Payment sent"
description="We emailed a receipt to you and the person you paid."
actions={
<>
<Button variant="secondary">View receipt</Button>
<Button>Back to overview</Button>
</>
}
/>
);
}
Statuses
Success, error, warning and information, for the outcome of an action.
import { Button, Card, Result } from '@halo-ds/react';
export default function Demo() {
return (
<div className="demo-grid-2">
<Card><Result size="sm" status="success" title="Payment sent" description="We emailed you a receipt." actions={<Button size="sm">Done</Button>} /></Card>
<Card><Result size="sm" status="error" title="Payment failed" description="Your bank declined it. Try another card." actions={<Button size="sm">Try again</Button>} /></Card>
<Card><Result size="sm" status="warning" title="Sent with a problem" description="Two of the five invitations bounced." actions={<Button size="sm">Check emails</Button>} /></Card>
<Card><Result size="sm" status="information" title="Request received" description="We will reply within two working days." actions={<Button size="sm">Done</Button>} /></Card>
</div>
);
}
Error pages
Illustrations for pages that can not show: not found, no access, server error, offline and maintenance.
import { Button, Card, Result } from '@halo-ds/react';
export default function Demo() {
return (
<div className="demo-grid-2">
<Card><Result size="sm" status="not-found" title="Page not found" description="The link may be old, or the page has moved." actions={<Button size="sm" variant="secondary">Go home</Button>} /></Card>
<Card><Result size="sm" status="no-access" title="You don't have access" description="Ask a workspace admin to invite you." actions={<Button size="sm" variant="secondary">Go home</Button>} /></Card>
<Card><Result size="sm" status="offline" title="You're offline" description="Check your connection." actions={<Button size="sm" variant="secondary">Try again</Button>} /></Card>
<Card><Result size="sm" status="maintenance" title="Back soon" description="We are making updates." actions={<Button size="sm" variant="secondary">Go home</Button>} /></Card>
</div>
);
}
More: https://halodesignsystem.dev/components/result