Feedback
Banner
Free16.2 KB gzippedA 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
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.
Scheduled maintenance
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.
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
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
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.
Scheduled maintenance
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 byaria-labeloraria-labelledby, else by thetitle, 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 hiddenrole="status"(orrole="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 underprefers-reduced-motion.
API reference
Banner
| Prop | Type | Default |
|---|---|---|
toneSemantic color. Status tones get a default icon. | "neutral""primary""accent""success""warning""danger""info" | "primary" |
variantVisual style: loud | "solid""soft" | "solid" |
sizePadding and type size. | "sm""md""lg" | "md" |
iconLeading icon, always decorative (hidden from assistive technology), so the text must carry the meaning. Status tones show a matching icon by default; pass | ReactNode | — |
titleShort bold lead-in, shown before the message. Also names the landmark. | ReactNode | — |
childrenThe message. For links inside it, use | ReactNode | — |
actionsButtons or Links after the message. | ReactNode | — |
dismissibleShows a dismiss button at the end. | boolean | false |
dismissLabelAccessible name of the dismiss button. Localize it here. | string | "Dismiss banner" |
openWhether the banner is shown (controlled). | boolean | — |
defaultOpenWhether the banner is shown at first (uncontrolled). | boolean | true |
onOpenChangeCalled with the next open state, e.g. | (open: boolean) => void | — |
persistKeyRemembers 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; | string | — |
position
| "static""sticky" | "static" |
alignContent alignment. | "start""center" | "start" |
containedKeeps the content within a centered max width (via | falsetrue"sm""md""lg""xs""xl""2xl""full""prose" | false |
liveAnnounces the banner to screen readers when it appears or its message changes. | "off""polite""assertive" | "off" |
liveMessageText announced when | 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)
Checking the examples above…
Lighthouse audit
Light mode
Score 10035 passed · 0 failed · 30 not applicable · 10 to check by hand
Dark mode
Score 10035 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
| Key | Action |
|---|---|
| Tab | Moves to the banner's action and close buttons. |
Roles and states
| Element | Role | States and properties |
|---|---|---|
| Banner | region | aria-labelledby → its title |
| Live region | status or alert | aria-live from live |
| Close button | button | aria-label |
Manual checks
Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.
| Check | What to test | WCAG 2.2 |
|---|---|---|
| Keyboard | Every 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) |
| Focus | Focus 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 readers | Names, 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) |
| Color | Meaning 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 reflow | At 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 targets | Click 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) |
| Motion | Animations respect the reduced-motion setting. | 2.3.3 (AAA) |