Inline or callout
The variant decides what the banner is, which in turn decides whether it can be dismissed.
An inline banner reports the outcome of something the user did. It has been read once it has been read, so it may carry a close button.
A callout states a standing fact that loads with the page: a trial expiring, a draft awaiting approval, an environment that is not production. Dismissing it would not make it untrue, so it cannot be dismissed. Passing dismissible to a callout does nothing, deliberately.
<template>
<!-- Reports an outcome, so it can be dismissed. -->
<NbBanner status="success" title="Changes requested" dismissible>
The author has been notified.
</NbBanner>
<!-- States a standing fact. `dismissible` is ignored. -->
<NbBanner
status="info"
variant="callout"
title="This draft is waiting for approval"
>
Visitors still see the published version.
</NbBanner>
</template>With an action
Put the way to resolve the banner in the action slot. Keep it to one or two controls: a banner is not a toolbar.
<template>
<NbBanner status="warning" title="Rebuild not confirmed">
The content is live in the API; the site may still serve old HTML.
<template #action>
<NbButton size="sm" variant="ghost" @click="check"
>Check rebuild</NbButton
>
<NbButton size="sm" variant="primary" @click="retry">Try again</NbButton>
</template>
</NbBanner>
</template>In the shell
flush drops the radius and the side borders so the banner meets both edges of the region holding it. This is what NbShell's #notification slot expects.
<template>
<NbShell>
<template #notification>
<NbBanner
status="warning"
variant="callout"
flush
title="Your trial expires in 3 days"
>
<template #action>
<NbButton size="sm" variant="ghost" href="/billing">Upgrade</NbButton>
</template>
</NbBanner>
</template>
</NbShell>
</template>Props
| Prop | Type | Default | Description |
|---|---|---|---|
status | 'info' | 'success' | 'warning' | 'error' | 'neutral' | 'info' | The tone. Picks the ground, the ink and the icon. |
variant | 'inline' | 'callout' | 'inline' | Reports an outcome, or states a standing fact. |
title | string | undefined | Short and declarative, no full stop. |
dismissible | boolean | false | Shows a close button. Ignored when variant="callout". |
icon | string | undefined | Overrides the icon that status would pick. |
hideIcon | boolean | false | Removes the icon. Colour must then not be the only cue. |
flush | boolean | false | Drops the radius and side borders, for edge-to-edge use. |
closeLabel | string | catalogue | Accessible label for the close button. Falls back to the string catalogue's close |
Slots
| Slot | Description |
|---|---|
default | The body text, rendered after title in the same paragraph. |
action | One or two controls that resolve the banner. |
Events
| Event | Payload | Description |
|---|---|---|
dismiss | — | Emitted when the close button is used. |
Icon and colour mapping
| Status | Icon | Ground | Ink |
|---|---|---|---|
info | info | --nb-c-info-surface | --nb-c-on-info-surface |
success | check-circle | --nb-c-success-surface | --nb-c-on-success-surface |
warning | warning | --nb-c-warning-surface | --nb-c-on-warning-surface |
error | warning-circle | --nb-c-danger-surface | --nb-c-on-danger-surface |
neutral | note | --nb-c-neutral-surface | --nb-c-on-neutral-surface |
These are semantic surface tokens, distinct from --nb-c-warning and friends. Those are inks, strong enough to set a word in and far too strong to fill a block with. In dark mode the grounds become a translucent wash of the same colour so the banner sits on the page instead of punching a hole in it.
Theming a single banner
Every rule reads from one pair of custom properties, so one banner can be retinted without reaching into the internals:
.my-banner {
--nb-banner-bg: var(--nb-c-layer-2);
--nb-banner-fg: var(--nb-c-text);
--nb-banner-border: var(--nb-c-layer-border-2);
}Accessibility
status="error"rendersrole="alert"witharia-live="assertive", so it interrupts. Every other status usesrole="status"witharia-live="polite".- The title and body are one
<p>, so a screen reader announces the banner as a single sentence rather than two fragments. - The icon is
aria-hidden; the text carries the meaning. - The close button is an
NbCloseButtonatsmin the banner's own ink, so it stays legible on every status. It takes its accessible name fromcloseLabel, else the catalogue'sclose.