NbBanner is a page-level message: a filled block that states something about the page or the task, sitting above or at the top of the content it concerns.
It is the third of three things that look superficially alike, and picking the wrong one is the usual mistake:
| Use | When |
|---|---|
NbBanner | Something is true about this page or task, and it stays on screen. |
NbMessage | A single form field has something to say about its own value. |
NbToast | Something just happened, and the news expires by itself. |
<template>
<NbBanner status="warning" title="Rebuild queued but NOT confirmed">
A hook accepted is the start of a build, not the end of one.
</NbBanner>
</template>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">Retry</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>Writing the message
Follow the same discipline the status colours imply. Say what happened in the title, without a full stop, and what to do about it in the body.
- Do:
title="Rebuild not confirmed", bodyThe content is live in the API; the site may still serve old HTML. - Don't:
title="Warning!", bodySomething went wrong. Please try again.
Never use colour as the only signal. Every status ships an icon for exactly this reason, and hideIcon should be reserved for banners whose meaning is already unambiguous from the text.