Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Feedback

Banner

Free16.2 KB gzipped

A full-width, page-level strip for announcements, promos, cookie notices, trial reminders, maintenance windows, and connection status. For a message inside the page content, use Alert instead.

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Tab · Full report

Import

tsx
import { Banner } from "@vjdesigns/vjdesigns-ui";

Importing only Banner adds about 16.2 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

A full-width strip for page- or site-wide messages, usually at the top of the page.

New: dark mode is here.

Switch themes from the settings menu.

Scheduled maintenance

Sunday 2–3 AM UTC. Saving may be briefly unavailable.
tsx
import { Banner, Button, Stack } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  return (
    <Stack gap={3} style={{ width: "100%" }}>
      <Banner tone="primary" title="New: dark mode is here." actions={<Button size="sm" variant="inverse">Try it</Button>}>
        Switch themes from the settings menu.
      </Banner>
      <Banner tone="warning" variant="soft" dismissible title="Scheduled maintenance">
        Sunday 2–3 AM UTC. Saving may be briefly unavailable.
      </Banner>
    </Stack>
  );
}

Remember dismissal

persistKey remembers a dismissal in local storage, so the banner stays closed on later visits.

tsx
import { Banner } from "@vjdesigns/vjdesigns-ui";

export function RememberDismissal() {
  return (
    <div style={{ width: "100%" }}>
      <Banner tone="info" variant="soft" dismissible persistKey="docs-banner-example" align="center" title="We've updated our privacy policy.">
        Dismiss this and it stays dismissed when you reload the page.
      </Banner>
    </div>
  );
}

Accessibility

A banner sits at the top of a page or section. Its dismiss button is named by dismissLabel. Set live when a banner appears in response to something, so it's announced; leave it off for banners that are there when the page loads.

Scheduled maintenance

The site will be read-only on Sunday from 2 to 3 a.m. UTC.
tsx
import { Banner } from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Banner tone="info" title="Scheduled maintenance" dismissible dismissLabel="Dismiss maintenance notice">
      The site will be read-only on Sunday from 2 to 3 a.m. UTC.
    </Banner>
  );
}

Translated

The dismiss button's default name comes from the locale (Brazilian Portuguese here); the message is your own text.

Pedido confirmado

Enviamos os detalhes para o seu e-mail.
tsx
import { Banner, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ptBR from "@vjdesigns/vjdesigns-ui/locales/pt-BR";

export function Translated() {
  return (
    <LocaleProvider locale="pt-BR" messages={ptBR}>
      <Banner tone="success" title="Pedido confirmado" dismissible>
        Enviamos os detalhes para o seu e-mail.
      </Banner>
    </LocaleProvider>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

New: dark mode is here.

Switch themes from the settings menu.

Scheduled maintenance

Sunday 2–3 AM UTC. Saving may be briefly unavailable.
tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

Usage notes

Accessibility:

  • Renders a <section> region landmark, named by aria-label or aria-labelledby, else by the title, else "Announcement". Give each banner on a page a distinct name.
  • Icons are decorative; status is carried by the text (and the default status icon shape), never by color alone.
  • With live, a visually hidden role="status" (or role="alert") region is filled just after the banner appears, so it is announced reliably.
  • Dismissing moves focus to the next focusable element after the banner (or the one before it), so keyboard focus is never lost.
  • The dismiss animation collapses the strip with --ease-standard; it is instant under prefers-reduced-motion.

API reference

Banner

Banner props
PropTypeDefault
tone

Semantic color. Status tones get a default icon.

"neutral""primary""accent""success""warning""danger""info""primary"
variant

Visual style: loud solid fill or calm soft tint.

"solid""soft""solid"
size

Padding and type size.

"sm""md""lg""md"
icon

Leading icon, always decorative (hidden from assistive technology), so the text must carry the meaning. Status tones show a matching icon by default; pass null to hide it.

ReactNode—
title

Short bold lead-in, shown before the message. Also names the landmark.

ReactNode—
children

The message. For links inside it, use <Link tone="neutral">: it inherits the strip's text color (verified on every tone) and stays underlined, so it is not identified by color alone.

ReactNode—
actions

Buttons or Links after the message. Buttons get a default variant, tone, and size that keep verified contrast on the strip (their own props still win): soft neutral on solid strips; solid tone (or solid neutral for neutral, accent, and warning) on soft strips. For a secondary action on a soft strip, use variant="outline" tone="neutral".

ReactNode—
dismissible

Shows a dismiss button at the end.

booleanfalse
dismissLabel

Accessible name of the dismiss button. Localize it here.

string"Dismiss banner"
open

Whether the banner is shown (controlled).

boolean—
defaultOpen

Whether the banner is shown at first (uncontrolled).

booleantrue
onOpenChange

Called with the next open state, e.g. false when the user dismisses it.

(open: boolean) => void—
persistKey

Remembers a dismissal in localStorage under this key, so the banner stays hidden on later visits. Use a new key (e.g. with a version) to show an updated banner again; resetBannerDismissal(key) forgets it. Server rendering and hydration render nothing until storage is read, so a dismissed banner never flashes (a visible one appears just after hydration). Falls back to memory when storage is blocked.

string—
position

sticky sticks to the top of the scroll container (--z-sticky) and sets --banner-height on <html> while shown, so pages can offset with scroll-padding-top: var(--banner-height, 0px) and keep focused content from being hidden under it (WCAG 2.4.11).

"static""sticky""static"
align

Content alignment.

"start""center""start"
contained

Keeps the content within a centered max width (via Container) while the color runs edge to edge. true uses xl; pass a size to change it.

falsetrue"sm""md""lg""xs""xl""2xl""full""prose"false
live

Announces the banner to screen readers when it appears or its message changes. "polite" uses role="status", "assertive" uses role="alert". Leave "off" for banners present on page load.

"off""polite""assertive""off"
liveMessage

Text announced when live is set. Defaults to the title and message when they are plain strings; pass this when either is JSX.

string—

Also accepts native <section> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Banner targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
TabMoves to the banner's action and close buttons.

Roles and states

Roles and states
ElementRoleStates and properties
Bannerregionaria-labelledby → its title
Live regionstatus or alertaria-live from live
Close buttonbuttonaria-label

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)