A short message beside the content it's about, in any tone, with an optional next step: a paused workflow, a refusal, a failed sync.
- 0.9 kB JS 2.6 kB CSS gzipped
- No serious axe issues
- Server-rendered, hydrates
- 44px touch targets
- Right-to-left
Invoices sync every hourChanges in Northwind Freight's ledger show here within the hour.
Couldn't reach the ledgerThe API key was revoked. Paste a new one in Settings, then sync again.
import type { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Callout } from "./ui/uicontext/components/Callout.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ stack: { display: "grid", gap: 12, inlineSize: "min(100%, 30rem)" } })// a neutral callout is a quiet status; a danger one is an alert, announced at onceexport const ConnectionNotes = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.stack)).children( Callout(h, { title: "Invoices sync every hour" }, "Changes in Northwind Freight's ledger show here within the hour."), Callout(h, { tone: "danger", title: "Couldn't reach the ledger" }, "The API key was revoked. Paste a new one in Settings, then sync again."), )When to use
A short message beside the content it's about, in any tone, with an optional next step: a paused workflow, a refusal, a failed sync. Use Banner instead when the message is about the whole product, not the content beside it.
Usage
import { Callout } from "./ui/uicontext/components/Callout.ts"export const ScheduleNote = <M>(h: Html.H<M>) => Callout(h, { title: "Runs every weekday" }, "It starts at 9:00 in the workspace's time zone.")Examples
Tones and a next step
Invoice sync is paused. Resume
Only admins can change spend limits.
Runs every weekday at 9:00.
Reconnected. Replay the run to try the step again.
import type { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Callout } from "./ui/uicontext/components/Callout.ts"import { sx } from "./ui/uicontext/components/Sx.ts"const styles = stylex.create({ stack: { display: "grid", gap: 12, inlineSize: "min(100%, 30rem)" } })// the tone shows in the dot; a link after the message is the next stepexport const WorkflowNotices = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.stack)).children( Callout(h, { tone: "warning", href: "#resume", linkLabel: "Resume" }, "Invoice sync is paused."), Callout(h, { tone: "danger" }, "Only admins can change spend limits."), Callout(h, { tone: "info" }, "Runs every weekday at 9:00."), Callout(h, { tone: "success" }, "Reconnected. Replay the run to try the step again."), )API reference
Options
| Name | Type | Description |
|---|---|---|
title | string | A few words above the message, in bold: "Couldn't reach the ledger". |
tone | "neutral" | "accent" | "danger" | "warning" | "success" | "info" | What it means: the dot's color, and danger makes it an alert; neutral, with no dot, by default. |
href | string | A page or setting that helps, linked after the message. |
linkLabel | string | The link's words; "Learn more" by default. |
style | Style | StyleX styles applied after the callout's own. |
Keyboard and accessibility
- A danger callout is an
alert, announced when it appears; any other is a politestatus. The tone's dot is hidden from screen readers. - The words must carry the meaning; the tone only colors it.
Installation
pnpm dlx shadcn@latest add checkfu/uicontext/alert