A band across the top about the whole product, such as a trial ending, with one action.
- 1.8 kB JS 3.4 kB CSS gzipped
- No serious axe issues
- Server-rendered, hydrates
- 44px touch targets
- Right-to-left
When to use
A band across the top about the whole product, such as a trial ending, with one action. Use Alert instead when the message is about one part of the page.
Usage
import { Banner } from "./ui/uicontext/components/Banner.ts"const Message = UiSchema.TaggedEnum({ DismissedNews: {} })export const News = (h: Html.H<typeof Message.Type>) => Banner(h, { tone: "info", title: "Exports now include comments.", action: { label: "See what's new", href: "/changelog" }, onDismiss: Message.DismissedNews() })Examples
Across the top of an app
Without inset it's a band, edge to edge. A state that still holds has no dismiss.
API reference
Options
| Name | Type | Default | Description |
|---|---|---|---|
tone | "neutral" | "info" | "warning" | "danger" | Neutral | Neutral by default; danger for something broken that needs action now |
titlerequired | string | — | What's happening, in one short sentence: "Your trial ends in 3 days." |
body | string | View.Content | — | More, when it helps: "Scheduled maintenance Sunday 02:00–03:00 UTC." |
action | BannerAction<Message> | — | — |
onDismiss | Message | — | Leave it out while the state still holds (a failed payment); give it for news. |
inset | boolean | — | A card inside a page instead of a band across the top. |
label | string | "Announcement" | The landmark's name; "Announcement" by default. |
style | Style | — | — |