Banner
ProA full-bleed announcement bar for promos, release notes and site-wide notices. Soft tones tint the background, message, icon and action from one semantic token, so the whole bar reads as a single hue.
Installation#
Usage#
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
Anatomy#
import {
Banner,
BannerOrnament,
BannerIcon,
BannerContent,
BannerAction,
} from "@/components/ui/banner"
<Banner>
<BannerOrnament />
<BannerIcon />
<BannerContent />
<BannerAction />
</Banner>Variants#
Soft tones tint the background from a single semantic token and color the icon, action, and message to match. The message takes a deep, tone-tinted ink (a dark blue, dark purple, ...) on light themes and lifts to a bright tint on dark ones, so it stays readable while the icon and action keep the pure hue. Every tone re-themes across light, dark, cream, and moonlight.
Solid#
Set appearance="solid" for a filled bar. Solid is designed for two theme-stable surfaces: the default inverse bar (flips with the theme) and the brand accent bar. The soft tones stay tinted because the hue tokens shift lightness per theme.
Festive#
Set appearance="festive" for a playful celebration bar: a flat, saturated fill behind white text, the natural home for launches, milestones, and holidays. It ignores the tone variant. Recolor the bar by overriding one CSS variable, --banner-festive-via, with a brand or flag color. Keep it deep and saturated so the white text stays legible across every theme.
Interactive (confetti)#
Add confetti to a festive bar to make it playful: it bursts once on mount and again on every click. The icon pops on the mount burst only, so clicking showers confetti while the icon stays still. The pieces are themed by the --banner-confetti-* tokens, which derive from the festive palette, so they re-tint with it (recolor the bar and the confetti follows). It is decorative and fully honors reduced-motion. Click the bars below.
Ornaments#
Drop a BannerOrnament in to peek a decorative flag, mascot, or emoji in from an edge. It clips to the bar and sits behind the message, tilting away from its side. Below, two Venezuela flags (rounded 16px, not circular) peek from the corners of a flat solid bar, with the confetti tinted to the flag's yellow and red. The flag itself is any element you like, sized and rounded however you want.
Alignment#
The default align="center" centers the message. Switch to align="between" to pin the message left and the action right, the natural home for a Button CTA.
Shape#
shape sets the bar's footprint. The default "bar" runs edge to edge, the classic strip atop a page. "inset" draws the same bar as a rounded card that sits inside the page gutter, above the navbar: place it in a SectionContainer (or any gutter) and it takes that width, its inner row trading the page-width cap for a card interior and a step more height.
Size#
size sets the strip's own height and side padding."md" (default) is the page bar, with the 24px page gutter."sm" is a compact strip for a panel, a tablet screen or the head of a card: 12px sides, a 32px row, the type a step down and a smaller close button, and no page-width cap. Use it instead of reaching into the inner row with selectors.
Dismissible#
Set dismissible to render a trailing close button. Uncontrolled by default (the banner hides itself); pass open / onOpenChange to control it, and always give a descriptive dismissLabel.
As child action#
Use asChild on BannerAction to render the link styles onto a framework link (e.g. Next.js <Link>) via Radix Slot, keeping client-side navigation.
API reference#
Banner
The full-bleed bar. Children land in an inner row; the close button and confetti layer are drawn for you. Forwards all native <div> props. Every part accepts className, merged last.
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "default" | "brand" | "purple" | "pink" | "teal" | "orange" | "info" | "success" | "warning" | "destructive" | "default" | The tone. The icon, message and action all carry it. |
| appearance | "soft" | "solid" | "festive" | "soft" | The fill. solid is defined for default (inverse) and brand; festive is a flat celebration bar that ignores the tone. |
| align | "center" | "between" | "center" | A centered message, or message left and action right (stacked on phones). |
| shape | "bar" | "inset" | "bar" | An edge-to-edge strip, or a rounded card inside the page gutter. |
| size | "md" | "sm" | "md" | The page bar (24px sides), or a compact strip (12px sides, 32px row, smaller type and close, no page-width cap) for panels and cards. |
| dismissible | boolean | false | Renders a trailing close button. |
| dismissLabel | string | "Dismiss" | The accessible label of the close button. |
| open | boolean | - | Visibility, controlled. A closed banner renders nothing. |
| defaultOpen | boolean | true | Visibility on first render, uncontrolled. |
| onOpenChange | (open: boolean) => void | - | Called when the banner is dismissed. |
| confetti | boolean | false | A burst on mount (with an icon pop) and on every click of the bar. Pairs with festive; off under reduced motion. |
| CSS variable | Description |
|---|---|
| --banner-festive-via | The fill of the festive bar. Override it on the banner or a parent; keep it deep enough for white text. |
| --banner-festive-to | A confetti accent alongside the festive fill. |
| --banner-confetti-{1,2,3} | The three confetti colors, derived from the festive stops by default. |
| --surface | Set to the fill of the bar, so a nested control blends with it. |
BannerIcon
The leading icon, tinted to the tone. Forwards all native <span> props.
BannerContent
The message, a deep tint of the tone. Forwards all native <span> props.
BannerAction
The inline call-to-action link, tinted to the tone. Forwards all native <a> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| asChild | boolean | false | Renders onto its single child (Radix Slot), such as a Next.js <Link>. |
BannerOrnament
A decorative flag, mascot or emoji that peeks in from an edge behind the message, clipped to the bar and aria-hidden. Forwards all native <span> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| side | "left" | "right" | "left" | The edge it peeks in from; it tilts away from that edge. |
| Data attribute | Description |
|---|---|
| data-side | "left" or "right". |