Callout

A tinted notice in the page, with an optional title and action.

Overview

A message the reader should see in the page, without being made to answer it.

Tone

Do
The import runs overnight.

3 uncategorised.

Sort them before the month closes.
import { Callout, Stack } from "@hackcove/ui";

<Stack gap="sm">
  <Callout tone="info">The import runs overnight.</Callout>
  <Callout tone="warn" title="3 uncategorised.">
    Sort them before the month closes.
  </Callout>
</Stack>
The tone matches how much the message matters: warn for a thing to check before going on.
Don't
The import runs overnight.

3 uncategorised.

Sort them before the month closes.
import { Callout, Stack } from "@hackcove/ui";

<Stack gap="sm">
  <Callout tone="danger">The import runs overnight.</Callout>
  <Callout tone="danger" title="3 uncategorised.">
    Sort them before the month closes.
  </Callout>
</Stack>
danger on a plain note cries wolf: when everything is red, a real failure no longer stands out.

Action

Do

Import failed.

The last file did not finish.
import { Button, Callout } from "@hackcove/ui";

<Callout
  tone="warn"
  title="Import failed."
  actions={
    <Button size="sm" variant="outline">
      Retry
    </Button>
  }
>
  The last file did not finish.
</Callout>
The action goes in actions, at the end of the row, so every callout puts it in the same place.
Don't

Import failed.

The last file did not finish.
import { Button, Callout } from "@hackcove/ui";

<Callout tone="warn" title="Import failed.">
  The last file did not finish. <Button size="sm">Retry</Button>
</Callout>
A button inside the body drops under the text and leaves the row without its action.

Usage

  • Pick the tone by how much the message matters: neutral for a note, info (the default) for something worth knowing, positive for a result, warn for a thing to check before going on, danger for a failure or something that cannot be undone. Keep danger for the real failure.
  • Add a title for a short bold lead-in; the body carries the detail.
  • Put the one action in actions, at the end of the row: a Button size="sm" or a TextLink stretch, which makes the whole callout the click target.
  • banner is the flat strip at the top of a Card flush; do not use it anywhere else.
  • A message that must be answered before the reader goes on is a Dialog; a field's own error is the error of its Field.

Accessibility

  • A Callout is a plain <div> with no role and no live region, so a screen reader does not announce it when it appears; the tone is colour and text, so say what happened in the words.
  • A title is a bold paragraph, not a heading, so it adds nothing to the heading outline.
  • Buttons and links in actions keep their own focus ring and keyboard behaviour.

API

Callout

A tinted notice box, with an optional bold title above its body. actions puts a button or link at the end of the row; banner makes it a flat strip (bottom border only, no radius) for the top of a Card flush (a padded card would inset it). With actions the box is relative, so a TextLink stretch there makes the whole callout its click target, like a link in a table row.


actions

A button or link at the end of the row, beside the title and body.

Type
ReactNode

banner

A flat strip: border-b only and no radius, to sit above a card body.

Type
boolean
Default
false

title
Type
ReactNode

tone

Defaults to "info".

Type
"positive" | "danger" | "neutral" | "info" | "warn"
Default
info