Notification Banner React component for Tailwind CSS v4
v1.0.0Added in 1.0.0
iOS-style React notification banners for messages, orders and reminders that drop from the top one at a time, with a queue.
Mount the host once and call notify() from anywhere: a banner drops in from the top edge with a soft spring (the phone ticks once if the page has seen a tap) and leaves on its own after the duration. It shows the app icon, name and time ("acum", "acum 2 min."), the sender's photo or an icon tile, a one-line title and two lines of text. Tap or click it to open (onPress runs and the banner goes). Swipe it up with a finger, or drag it up with the mouse, to throw it away; a short drag springs back. Pull it down and, past 40px of rubber-banded pull, the grabber arms, the phone ticks and the card grows to the full text and its actions (44px buttons on touch); with a mouse, the chevron under the text does the same. The × appears on hover and on keyboard focus (touch uses the swipe). Timers pause while you hover, hold, focus or expand a banner and while the tab is hidden. More banners wait in a queue: the next one peeks out under the card with a "+2" chip and drops in after the current one leaves; a banner sent again with the same id updates in place and cross-fades its text. Keyboard: the hotkey (Alt+N, ⌥N on a Mac) focuses the banner without stealing focus on arrival; Enter opens it, ArrowDown expands and ArrowUp collapses, Tab reaches the actions, the chevron and the ×, and Escape dismisses it and returns focus to where you were. Each new banner is read once by screen readers. Below a 576px wide host banners span the top with 8px gutters under the notch; wider, they are a 380px card at the top end.
Notification Banner is a Pro React component in the React mobile components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add notification-banner, together with Avatar, Button, useControllableState, Relative time, useLocale and 5 more and the npm packages motion and lucide-react.
Add to a project
Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup
npx wingo-ui@latest add notification-bannerNotification Banner is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans
Usage
Import NotificationBanner from @/components/ui/notification-banner.
import { useEffect, type ReactNode } from "react"
import { ShoppingCart } from "lucide-react"
import { NotificationBanner, notify } from "@/components/ui/notification-banner"
const usd = new Intl.NumberFormat("en-US", { style: "currency", currency: "USD", maximumFractionDigits: 0 })
export function CrmShell({ children }: { children: ReactNode }) {
return (
<>
{children}
<NotificationBanner
appName="Northwind CRM"
labels={{ queued: (n) => `+${n} waiting` }}
/>
</>
)
}
export function useNewOrders(orders: { id: number; total: number; locker: string }[], openOrder: (id: number) => void) {
useEffect(() => {
const order = orders.at(-1)
if (!order) return
notify({
id: `order-${order.id}`,
title: "New order",
message: `Order #${order.id} · ${usd.format(order.total)} · ${order.locker}`,
icon: <ShoppingCart />,
tone: "success",
onPress: () => openOrder(order.id),
actions: [{ label: "View order", onSelect: () => openOrder(order.id) }],
})
}, [orders, openOrder])
}Props
positiondefault"top-right""top-center" | "top-right" | "top-left"Where the card sits once the host is at least 576px wide (a container query, so a phone frame on a desktop still gets the phone layout). Narrower, banners always span the top with 8px gutters.
strategydefault"fixed""fixed" | "absolute"fixed pins the host to the viewport (the app default). absolute places it inside a relative container: a phone frame, an embedded panel.
widthdefault380numberCard width in px in the wide layout. Phones always use the full width minus the gutters.
offsetdefault8numberpx below the top safe area. In the wide layout it is also the distance from the side.
safeAreadefaulttruebooleanPads env(safe-area-inset-top) so banners drop in under the notch or the Dynamic Island. It is 0 in desktop browsers and iframes.
variantdefault"glass""glass" | "solid"glass: a translucent popover with a strong backdrop blur, like iOS (solid where backdrop-filter is missing). solid: the plain popover surface.
radiusdefault"lg""sm" | "md" | "lg"Card corners: sm 12px, md 16px, lg 24px (iOS). The action buttons and the media tile follow.
showAppHeaderdefaulttruebooleanThe row with the app icon, the app name and the time. Off, the time moves next to the title (a compact chat banner).
appNamedefault""stringThe app name in the header of every banner (a banner's own appName wins). The app icon shows its first letter on the tone's fill; empty shows a bell.
appIconReactNodeReplaces the letter tile in the header (a 20px logo). A banner's own appIcon wins.
durationdefault5000numberms a banner stays before it leaves. The clock pauses while it is hovered, held, focused or expanded. A banner's own duration or sticky wins.
expandabledefaulttruebooleanPull down, the chevron, a tap on a banner without onPress, or ArrowDown show the full text and the actions. Off, the actions never show.
maxQueuedefault5numberHow many banners may wait behind the one on screen. Past it the oldest queued banner is dropped (its onDismiss runs with "dropped").
hapticsdefaulttruebooleanA light tick when a banner arrives (only once the page has seen a tap) and a selection tick when it expands. Through lib/haptics.
hotkeydefault"alt+n"stringMoves focus to the banner on screen; Escape then dismisses it and returns focus. Empty turns it off.
pauseWhenPageIsHiddendefaulttruebooleanTimers stop while the tab is in the background, so a banner sent then is still there when you come back.
hostIddefault""stringShows only banners sent with notify({ hostId }). Several independent hosts on one page (a phone preview next to the app). A second host with the same id stays empty.
localedefault""stringFormats the time ("2 min ago", "il y a 2 min") through relative-time. Empty uses the UIProvider locale, then the page language.
labelsPartial<NotificationBannerLabels>Every string: region "Notifications", dismiss "Dismiss", expand "Show more", collapse "Show less", queued(n) "{n} more", now "now", hint "Swipe up to dismiss, pull down for more" (read with each banner). DEFAULT_NOTIFICATION_BANNER_LABELS has the English set.
classNamesPartial<Record<"item" | "header" | "body" | "media" | "title" | "message" | "actions" | "action" | "close" | "expand", string>>Extra classes for the parts of every banner.
classNamestringExtra classes for the host section (the full-width layer at the top).
Parts
notify
functionShows a banner and returns its id. Works from anywhere (handlers, fetch helpers, outside React) and before the host mounts; ignored on the server. Options: { id?, hostId?, title, message?, icon?, avatar?: { src?, name }, appName?, appIcon?, time? (default now), tone?, color?, onPress?, actions?: { label, onSelect, tone?: "neutral" | "danger" }[], duration?, sticky?, defaultExpanded?, onDismiss?(reason) }. The same id updates the banner in place. Signature: (options: NotificationBannerOptions) => string. notify.update (id: string, options: Partial<NotificationBannerOptions>) => boolean: Changes a shown or queued banner in place (upload 2/3, a new count) and restarts its clock. false when the id is gone. notify.dismiss (id?: string) => void: Removes one banner, or every banner (shown and queued) without an id. onDismiss runs with "api".
useNotificationBanners
hookThe banner on screen and the ones waiting, for a counter or a "clear all" button. Signature: (hostId?: string) => { current: NotificationBannerRecord | null; queue: NotificationBannerRecord[] }.
NotificationBannerCard
componentOne banner as a still surface, without the store, timers or gestures: the same options plus variant, radius, showAppHeader, expanded / defaultExpanded / onExpandedChange, onClose, queued, locale, labels and classNames. For previews and settings screens. Props: NotificationBannerCardProps.
DEFAULT_NOTIFICATION_BANNER_LABELS
constantThe English strings: region, dismiss, expand, collapse, the queued count, now and the swipe hint. Spread it and override what you translate.
Examples
A queue of three
Three calls in a row: the first drops in, the next peeks out under it with a +2 chip. In a host 576px or wider it is a card at the top end.
Compact chat banner
Solid surface, no app row: the time sits next to the sender, like a messenger.
Sticky, needs an answer
A new version banner that arrives expanded and stays until you reload, postpone or swipe it away.
Updating in place
The same id sent again: 1/3, 2/3, 3/3, then a success banner, without a new drop.
Brand tone for the marketplace
Northwind Market colors its app icon with the brand orange; the buyer's photo stays the media.
British locale
locale="en-GB" with the default labels: a banner sent a few minutes ago reads "3 min ago" and times use 24 hours.
Dependencies
Files
- components/ui/notification-banner.tsx
FAQ
Is the React Notification Banner component free?
The preview, props and docs are free; copying the source needs a Pro plan. See plans.
How do I install Notification Banner?
Run npx wingo-ui@latest add notification-banner. It also adds the Wingo UI items it builds on (Avatar, Button, useControllableState, Relative time, useLocale and 5 more) and the npm packages motion and lucide-react. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/notification-banner.
See also
More React mobile components
Articles using this component
- Web App That Feels Native on a Phone: 12 React Fixes
Mobile UI in React11 min read