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>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>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>Usage
- Pick the
toneby how much the message matters:neutralfor a note,info(the default) for something worth knowing,positivefor a result,warnfor a thing to check before going on,dangerfor a failure or something that cannot be undone. Keepdangerfor the real failure. - Add a
titlefor a short bold lead-in; the body carries the detail. - Put the one action in
actions, at the end of the row: aButton size="sm"or aTextLink stretch, which makes the whole callout the click target. banneris the flat strip at the top of aCard 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 theerrorof itsField.
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
titleis a bold paragraph, not a heading, so it adds nothing to the heading outline. - Buttons and links in
actionskeep 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.
actionsA button or link at the end of the row, beside the title and body.
- Type
ReactNode
bannerA flat strip: border-b only and no radius, to sit above a card body.
- Type
boolean- Default
false
title- Type
ReactNode
toneDefaults to "info".
- Type
"positive" | "danger" | "neutral" | "info" | "warn"- Default
info