Callouts
On this page
A callout is a notice inside the page: information about what's shown, a warning to keep in mind, or an error that stopped something loading. Unlike a toast, it stays until the situation changes.


Figure 1: Info, success, warning and danger callouts; the danger callout has a Try again action
<div class="ph-callout ph-callout--danger" role="alert">
<div class="ph-callout-body">
<p class="ph-callout-title">Couldn't load orders</p>
<p>The server took too long to answer.</p>
</div>
<button type="button" class="ph-btn ph-btn--sm ph-callout-action">Try again</button>
</div>
| Class | Role | Use for |
|---|---|---|
.ph-callout | role="note" | Information: sample data, how something works |
.ph-callout--success | role="status" | Something finished and the page now reflects it |
.ph-callout--warning | role="note" | Something to keep in mind: a device offline, a limit close |
.ph-callout--danger | role="alert" | Something failed: loading, saving, a connection |
| Part | What it is |
|---|---|
.ph-callout-body | The text. Can be one sentence, or a title and a sentence. |
.ph-callout-title | A bold first line |
.ph-callout-action | A button on the right (use .ph-btn--sm) |
You can put an icon (.ph-icon) before the body.
When the error comes from the server
Put the server's message on the page with textContent, never by building HTML from it:
callout.querySelector('p:not(.ph-callout-title)').textContent = error.message;
phApp.fetchJSON errors already have a readable message. See
JavaScript API.
React
import { Callout, StyledButton } from 'ph-app-kit-react';
<Callout severity="error" action={<StyledButton onClick={load}>Try again</StyledButton>}>
Couldn't load orders.
</Callout>
Guidelines
- Say what happened and what to do next: "Couldn't load orders. Check your connection, then try again."
- Place page-wide callouts straight after the page header; place others at the top of the card they're about.
- Don't stack several callouts. Combine them, or fix the cause.
Related
- Empty states
- Toasts
- Page patterns: loading, empty and error states