vaiperui

components / banner

Banner

Full-width page-level message, with an optional action and close button.

How to use

Fills the width of its container with no radius, so place it at the top of the page. Use it for maintenance windows, announcements and trial notices. Same status roles as `Alert`.

preview
Scheduled maintenance today at 10 PM.
Banner.tsx
import { Banner, Button } from "vaiperui";
<Banner
action={<Button size="sm" variant="transparent">Learn more</Button>}
onDismiss={() => setOpen(false)}
>
Scheduled maintenance today at 10 PM.
</Banner>

Colors

preview
primary
primary
success
success
warning
danger
colors.tsx
<Banner variantColor="primary">primary</Banner>
<Banner variantColor="success">success</Banner>
<Banner variantColor="warning">warning</Banner>
<Banner variantColor="danger">danger</Banner>

Sizes

preview
sm
sm
md
md
lg
lg
sizes.tsx
<Banner size="sm">sm</Banner>
<Banner size="md">md</Banner>
<Banner size="lg">lg</Banner>

Custom color

preview
Violet
Violet
custom-color.tsx
<Banner customColor="#8b5cf6">Violet</Banner>

Props

PropValuesDefaultDescription
variantColorprimary | success | warning | dangerprimaryColor and default icon. warning and danger use role=alert, the rest role=status
customColorstring | { light, dark }noneAny CSS color (or a pair per theme). Overrides variantColor
sizesm | md | lgmdPadding and text size
iconReactNode | falsestatus iconYour own icon, or false to hide it
actionReactNodenoneSlot for an action, such as a small ghost Button or a link
onDismiss() => voidnoneShows the close button and runs on click; you decide whether to unmount
dismissLabelstringDismissAccessible name of the close button
(native)HTMLAttributes<HTMLDivElement>nonerole (overrides the default), className, style, aria-*, ref, etc.

Accessibility

  • Same roles as `Alert`: `role="alert"` for warning and danger, `role="status"` for primary and success; `role` can be overridden.
  • A banner is a plain `div`, not a landmark; it does not get `role="banner"`.
  • The status icon is `aria-hidden`.
  • The close button is a real `<button>` with `aria-label` from `dismissLabel` (default "Dismiss").
  • The `action` slot renders your own element; keep it a focusable button or link.

Keep in mind

  • Translate `dismissLabel`; the default is English.
  • Do not rely on color alone; the message text must state what happened.
  • Dismissing does not manage focus, and a banner shown at load may not be announced by every screen reader.