Banner
A message in the page flow about the page or section it sits in: a problem, a precondition, a result, or something new. It stays until it's resolved, and it never blocks.
Playground
Dismiss it to see the close; it comes back.
<Banner
variant="warning"
title="Calibration is out of date"
description="The CTD on Kystdata 3 was last calibrated 14 months ago."
>
{#snippet action()}
<Button size="sm">Schedule service</Button>
{/snippet}
</Banner> Variants
Each one says when to use it. The intent tints the surface and the icon. Text stays in the normal foreground colors, so it's as readable as the rest of the page.
Sizes
md is the default. sm is for forms, sheets and dense panels, where a md banner would outweigh the fields around it. A sm banner with children only makes a one-line note.
With an action
When there's a fix, put it in the banner. When it's narrow, the action drops below the text.
Rich description
Pass a snippet when the description needs a link or emphasis. Links take the foreground color with an underline.
Dismissible
For news and hints, never for a problem that still applies. The banner hides itself; use ondismiss to remember it.
<Banner
variant="info"
icon="sparkles"
title="New: calendar subscription"
dismissible
ondismiss={() => localStorage.setItem('seen-calendar-news', '1')}
/> Rules
- One banner per region. Two stacked banners compete; merge them or pick the one that matters.
- Put it where the problem is: at the top of the page for the page, inside the section or form for that section. Never floating.
- Title says what, description says why or what to do. A title alone is fine; a paragraph is not. Two lines of description at most.
- If the fix is an action, put the button in the banner. Use a secondary button, size sm (xs in a sm banner). Not primary: the page has its own.
- Don’t change the icon to something decorative. The default icon carries the meaning for anyone who can’t tell the colors apart.
- Only dismissible if it’s safe to forget. Warnings and errors that still apply stay until they’re fixed. Remember the dismissal with ondismiss, or it comes back on reload.
- Not a toast. If it’s only true for a moment (“Saved”), use a toast. A banner is still true when you scroll back.
- Announce it only when it appears because of something the user did: role="alert" for warning and danger, role="status" for the rest. A banner present on load stays silent.