Use it for marketing chrome at the very top of a store or product page. It takes real space in the flow, never covers content, and stores nothing itself: onDismiss is where you remember the choice.
When not to use
For a message about the person's own work, such as a failed sync or a reached quota, use Alert. Several banners at once are too much.
Use it for marketing chrome at the very top of a store or product: a sale with a figure and a
deadline, a holiday notice, a launch. It takes real space in the page, never covers content and
remembers nothing on its own. For a status message about the person's own work (a failed sync, a
quota reached), use alert instead.
import { PromoBanner, PromoBannerAction } from "@/components/ui/promo-banner"export function SaleBar() { return ( <PromoBanner id="winter-sale-2026" variant="sale" figure="−30%" action={<PromoBannerAction href="/sale">Shop the sale</PromoBannerAction>} > Winter sale, last week: shells, layers and mitts. </PromoBanner> )}
The bar is a flap hinged on the top edge of the page. On the first render its space is already
reserved, so the page below never moves while it loads; the flap swings down on its hinge and
settles. Pressing the close ball squashes it and dips the flap 2 px; on release the flap swings up
and away and the page rises into the space on a spring that never bounces. temperament="calm"
keeps the swing with no overshoot.
variant="sale" cuts the lower edge in half-balls, like a coupon's perforation, and puts figure
in a tile on the left in primary. announcement (the default) is a plain strip with a status dot.
The component stores nothing: no localStorage, no cookie. The app owns it. onDismiss(id) is the
place to write a cookie, a user preference or a database row, and open={false} on the next visit
keeps the bar out of the HTML, so nothing flashes. Change id for a new campaign and it shows again.
// app/layout.tsx (server component)import { cookies } from "next/headers"import { SaleBar } from "./sale-bar"const CAMPAIGN = "winter-sale-2026"export default async function Layout({ children }: { children: React.ReactNode }) { const dismissed = (await cookies()).get("dismissed-banner")?.value === CAMPAIGN return ( <html lang="en"> <body> <SaleBar campaign={CAMPAIGN} initiallyOpen={!dismissed} /> {children} </body> </html> )}
The bar sits in the flow, above your header, and never covers it. With sticky it stays at the top
of the viewport; it writes its height to --promo-banner-height on <html> (0px once closed,
following the dismiss frame by frame), so a sticky header can sit right below it:
messages takes a list; arrows roll them vertically. cycle (off by default) rolls to the next one
every 7 s (or the period you pass, in ms), only while the bar is on screen in a visible tab; it
stops on hover and on focus, and a pause button is shown.
The bar is a <section> with an accessible name (label, default "Announcement" or "Sale"), so
it is a landmark region. It is never role="alert" and never takes focus on its own.
The close control is a real button named by dismissLabel, with a 44 px target. When focus was
inside the bar, dismissing it moves focus to the next focusable element after it.
Arrows and pause are buttons with names (labels), 32 px. The message viewport is
aria-live="polite" when changed by hand and off while cycling; hidden copies of the messages
(they reserve the height of the longest) are aria-hidden and inert.
The status dot, the shadow and the perforation are decorative: aria-hidden or pure CSS, and
they never take a pointer.
Text is foreground on muted and primary-foreground on primary, AA in both themes.
The flap fades in and out without the swing, the page takes or gives back the space at once, and
messages swap with a fade. The cycle does not run. The still bar is the same finished design.
Motion only, no canvas. Every movement is a transform or opacity on the flap, except the
height of the region, which animates only on a dismiss or a later open (never on load).
Nothing runs at rest. The optional cycle is a single timer, stopped off screen, in hidden tabs,
on hover and on focus.
One ResizeObserver keeps --promo-banner-height current; it is removed with the bar.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 6.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, motion.
Dependencies
motion · peer
Triggers
press, entering the viewport
Reduced motion
The banner fades in and out without the swing, the page takes or gives back the space at once, and messages swap with a fade; the cycle does not run.
Keyboard
Tab
Moves through the action link, the message arrows, the pause button and the close button
Enter
Activates the focused link or button; on the close button, dismisses the banner and moves focus to the next control on the page
Space
Activates the focused button (the close ball charges while the key is down)
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)