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.

Info, success, warning and danger calloutsInfo, success, warning and danger callouts

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>
ClassRoleUse for
.ph-calloutrole="note"Information: sample data, how something works
.ph-callout--successrole="status"Something finished and the page now reflects it
.ph-callout--warningrole="note"Something to keep in mind: a device offline, a limit close
.ph-callout--dangerrole="alert"Something failed: loading, saving, a connection
PartWhat it is
.ph-callout-bodyThe text. Can be one sentence, or a title and a sentence.
.ph-callout-titleA bold first line
.ph-callout-actionA 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.