Skip to content

Banner

A notification banner: an icon chip, content, and an optional dismiss button. The variant picks the chip color and glyph, and the live-region role: status for info, success, and pending, alert for warning and danger. pending wears a spinner in the chip for work still running. Without a Banner.Title it is a compact one-liner, with one it stacks. The banner owns no open state, so render it inside an {#if} to show and hide it.

<Banner variant="warning">
<Banner.Title>Module deprecated</Banner.Title>
<Banner.Description>my-camera uses a module that is no longer maintained.</Banner.Description>
<Banner.Actions>
<button class="button">Update module</button>
</Banner.Actions>
<Banner.Close onclick={dismiss} />
</Banner>
  • variant sets the chip color, the glyph, and the live-region role. info, success, and pending are status, warning and danger are alert. pending spins in the chip.
  • With no Banner.Title the banner is the compact one-liner. A title stacks it.
  • The parts give you the layout. Each lands in its own cell, so what goes inside is your markup.
  • It has no open state. Wrap it in {#if} to show and hide it.
  • placement="block" is the full-width strip for the top of a page.

Every part is a property on Banner. A banner renders a <div>.

<Banner variant="warning">
<Banner.Icon>...</Banner.Icon>
<Banner.Title>title</Banner.Title>
<Banner.Description>description</Banner.Description>
<Banner.Actions>...</Banner.Actions>
<Banner.Details summary="Details">...</Banner.Details>
<Banner.Close onclick={dismiss} />
<Banner.Progress value={elapsed} label="Time until dismissed" />
</Banner>

A title, a description, and an actions row. Use the neutral button class for the emphasized action and text-sm font-medium text-link for a secondary one.

Code
Stacked.svelte
<script lang="ts">
import { Banner } from "@viamrobotics/prime-ui";
</script>
<div class="not-content">
<Banner variant="warning">
<Banner.Title>Module deprecated</Banner.Title>
<Banner.Description>
my-camera uses a module that is no longer maintained.
</Banner.Description>
<Banner.Actions>
<button type="button" class="button">Update module</button>
<a href="#changelog" class="text-sm font-medium text-link">View changelog</a>
</Banner.Actions>
<Banner.Close />
</Banner>
</div>

Leave the title out and the description sits on one line, with the actions inline beside it.

Code
Compact.svelte
<script lang="ts">
import { Banner } from "@viamrobotics/prime-ui";
</script>
<div class="not-content">
<Banner variant="info">
<Banner.Description>A new version is available.</Banner.Description>
<Banner.Actions>
<a href="#update" class="text-sm font-medium text-link">Update now</a>
</Banner.Actions>
<Banner.Close />
</Banner>
</div>

Banner.Close takes a native onclick. The banner holds no state, so the consumer owns {#if}.

Code
Dismissable.svelte
<script lang="ts">
import { Banner } from "@viamrobotics/prime-ui";
let shown = $state(true);
</script>
<div class="not-content flex flex-col gap-3">
{#if shown}
<Banner variant="success">
<Banner.Description>Your changes were saved.</Banner.Description>
<Banner.Close onclick={() => (shown = false)} />
</Banner>
{:else}
<button type="button" class="button w-fit" onclick={() => (shown = true)}>Show banner</button>
{/if}
</div>

variant="pending" shows a spinner in the chip for work still running. Banner.Progress pins a bar to the bottom edge, such as a countdown, and Banner.Icon replaces any variant’s glyph with your own.

Code
Pending.svelte
<script lang="ts">
import { Banner } from "@viamrobotics/prime-ui";
let elapsed = $state(0);
$effect(() => {
const timer = setInterval(() => {
elapsed = elapsed >= 100 ? 0 : elapsed + 2;
}, 100);
return () => clearInterval(timer);
});
</script>
<div class="not-content">
<Banner variant="pending">
<Banner.Description>Restarting the machine.</Banner.Description>
<Banner.Progress value={elapsed} label="Time until the restart finishes" />
</Banner>
</div>

Banner.Details is a disclosure under a divider. Its content is set in small monospace type.

Code
WithDetails.svelte
<script lang="ts">
import { Banner } from "@viamrobotics/prime-ui";
</script>
<div class="not-content">
<Banner variant="danger">
<Banner.Title>Failed to start module</Banner.Title>
<Banner.Description>The module exited before it became ready.</Banner.Description>
<Banner.Details summary="Error output">
<pre>exit status 1: missing config attribute "board"</pre>
</Banner.Details>
<Banner.Close />
</Banner>
</div>

placement="block" drops the side and top borders and spans the full width.

Code
Block.svelte
<script lang="ts">
import { Banner } from "@viamrobotics/prime-ui";
</script>
<div class="not-content">
<Banner variant="warning" placement="block">
<Banner.Description>Scheduled maintenance begins at 02:00 UTC.</Banner.Description>
<Banner.Close />
</Banner>
</div>

Stacked

Compact

Every part takes class on its element. Each part wears a component class from Component classes, so the same look works without Svelte.

Part Component class
Banner banner, banner-<variant>, and banner-block for the block placement
Banner.Icon banner-chip
Banner.Title banner-title
Banner.Description banner-description
Banner.Actions banner-actions
Banner.Details banner-details
Banner.Close icon-button banner-close
Banner.Progress progress banner-progress

Banner.Details is built on Collapsible, so bits-ui sets its attributes.

Part Attribute Value
Details data-state open or closed
Details data-disabled present when disabled
KeyAction
TabFocuses each action, the close button, and the details trigger.
Enter / SpaceOn the details trigger, opens or closes the content.
PropTypeDefaultDescription
idstringElement id. null is not accepted.
variantBannerVariant'info'The tone: chip color, default glyph, and live-region role.
placement'inline' | 'block''inline'block spans the full width with only a bottom border.
roleHTMLAttributes<HTMLDivElement>['role']The live-region role. Defaults by variant: status for info, success, and pending, alert for warning and danger. Pass null for none, when an ancestor already announces.

Plus everything in HTMLAttributes<HTMLDivElement>, spread onto the element.

A row of actions in a Banner. It holds whatever the consumer puts in it, such as a button and a link. In the compact banner it sits inline on the right.

Takes extraClasses, children, ...restProps }: Props as its props.

The dismiss button of a Banner, labeled Dismiss. It renders a close icon by default. Pass children to replace the icon, and aria-label to replace the label. The banner owns no open state, so handle onclick and remove the banner yourself.

PropTypeDefaultDescription
idstringElement id. null is not accepted.

Plus everything in HTMLButtonAttributes, spread onto the element.

The body copy of a Banner.

Takes extraClasses, children, ...restProps }: Props as its props.

A disclosure under a divider in a Banner. The summary is the trigger label, and the children are the content, set in small monospace type.

<Banner.Details summary="Stack trace">{trace}</Banner.Details>
PropTypeDefaultDescription
idstringElement id. null is not accepted.
bind:openbooleanfalseWhether the content is shown. Two-way bindable.
summarystring'Details'The trigger label.

Plus everything in HTMLAttributes<HTMLDivElement>, spread onto the element.

The icon chip of a Banner. Its children replace the variant glyph, such as a spinner for a pending state or a custom icon.

Takes extraClasses, children, ...restProps }: Props as its props.

A Progress pinned to the bottom edge of a Banner, inside the border. It takes Progress’s props.

<Banner.Progress value={elapsed} max={duration} label="Time until dismissed" />

Takes extraClasses, ...restProps }: Props as its props.

The heading line of a Banner. Its presence switches the banner from the compact one-liner to the stacked layout.

Takes extraClasses, children, ...restProps }: Props as its props.