Feedback

Banner

Page-level dismissible region landmark that surfaces a persistent informational, success, warning, or danger message.

import { Banner } from '@lostgradient/cinder';
feedbacknotice
01

Overview

Reference usage

Full-width announcement strip for page-level alerts, promotions, or system messages.

Usage

svelte
<script lang="ts">
  import { Banner } from '@lostgradient/cinder';
</script>

<Banner>Your message here.</Banner>

Connection presets

A preset carries the tone, the accessible name, the words, a glyph and the actions of a connection or restart state, so no page words its own. Every preset is non-dismissible and labels its retry "Try again". Pass the facts; the preset writes the sentence:

svelte
<script lang="ts">
  import { Banner } from '@lostgradient/cinder';

  let seconds = $state(4);
  let attempt = $state(3);
</script>

<Banner
  preset="unreachable"
  dataUpdatedAt={loadedAt}
  retryInSeconds={seconds}
  {attempt}
  onRetry={retryNow}
/>

That reads "Can’t reach the Interborough server. Showing what loaded as of 10:44 AM CST. Changes are off until it’s back. Retrying in 4 s (attempt 3 of 8)." The "as of" time is absolute with its zone, and names the day when the data is from another day. It is never "2 minutes ago".

Preset Tone Words Actions
offline warning You’re offline. Showing what loaded as of 10:44 AM CST. Changes are off until you’re back. Retrying in 8 s. Try again
unreachable warning Can’t reach the Interborough server. Showing what loaded as of 10:44 AM CST. Changes are off until it’s back. Retrying in 4 s (attempt 3 of 8). Try again
stopped warning Stopped retrying. Can’t reach the Interborough server. Showing what loaded as of 10:44 AM CST. Changes are off until it’s back. Try again (primary)
out-of-date warning Can’t reach the Interborough server. Showing what loaded as of 10:44 AM CST. Retries stopped after 8 attempts. Try again (primary)
refresh-failed warning Couldn’t refresh this page. Showing what loaded as of 10:44 AM CST. Try again
restarting info Restarting Interborough. Your changes are saved. Running work picks up where it stopped; reviews stay waiting. none
reconnecting info Reconnecting… attempt 2 of 8. Your changes are saved. Running work picks up where it stopped; reviews stay waiting. Try again
restart-failed warning Interborough didn’t come back. Your changes were saved first. Showing what loaded as of 10:44 AM CST. Changes are off until it’s back. Restart again (primary), Open Health
back-online success Back online. Updated just now. none

out-of-date is stopped for a page that is only read (Health), and a read-only page that is still retrying passes consequence={false} to unreachable so no sentence says changes are off. offline shows a wifi-off glyph, and unreachable, stopped and out-of-date an unplugged glyph; pass icon to draw another. restarting, restart-failed and back-online never offer Try again, with or without onRetry. restart-failed takes onRestart and onOpenHealth, or healthHref to make Open Health a link. back-online is a toast in the design; the preset carries the same words for a surface that cannot show one, and BANNER_BACK_ONLINE_COPY is the string a toast uses.

A page changes facts, not wording. subject completes "Showing … as of …" ("Showing reviews as of 10:44 AM CST."), consequence replaces the sentence that says what is off ("Start run is off until the connection is back.") or, as false, leaves it out, and title replaces the bold lead. retryVariant="primary" moves the emphasis for a page whose retries have stopped. bannerPresetCopy(preset, facts) writes the same words for anywhere else they are needed.

Passing children replaces the generated words and keeps everything else; with children, dataUpdatedAt shows the live relative notice ("Showing data from 2 minutes ago") instead. Use a banner only for the whole application or a page-wide condition; show a failure of one field, row or step where it happened.

Title, glyph, neutral tone and sticky

title sets a bold lead. With a preset it runs inline as the first words of the sentence; on a plain banner it sits on its own line above the message, and titleLayout moves it either way. icon draws a decorative glyph at the start; a success banner leads with a check-circle unless icon draws another. variant="neutral" is a notice that is not a status, such as a setting the person chose; it takes a soft tint of the accent hue, and like every tone its edge is painted in its own fill, so no tone draws a visible border. A banner is a full-width strip with square corners: a notice inside a page column that should read as a rounded surface is a Callout. sticky keeps the banner at the top of its scroll container, and paints the page canvas over the 16px band above it, so rows scrolled under it do not show through the container's top padding.

svelte
<script lang="ts">
  import { Banner, Button } from '@lostgradient/cinder';
</script>

<Banner variant="warning" dismissible={false} sticky title="1 change waits for a restart">
  Workflow claim renew interval. Running work picks up where it stopped; reviews stay waiting.
  {#snippet actions()}
    <Button variant="secondary" size="sm" label="Revert 1 change" />
    <Button variant="secondary" size="sm" label="Restart now" />
  {/snippet}
</Banner>

The actions sit at the inline end of the message's row, before the dismiss button, on one line and centred on the row. The banner reads its own width, not the viewport's: below 560px of it the actions drop under the message, in a row that wraps. A banner's message keeps the readable measure (90 characters wide at most) and wraps so that its last line is never a lone word (text-wrap: pretty), and its action stays at the band's trailing edge. A message of one line sits on the centre of the action beside it; a message of two lines is taller than the action, and the action centres on it. A button label never wraps. Below 640px, and on a touch pointer, each action is 44px tall. stackActions goes further below 640px: the actions take a row of their own, one above the next, each a full-width button, which is how a phone's restart notice offers Revert and Restart now.

Feature

variant="feature" announces something new or invites the person to try a feature. It is calm and has no images: the flair comes from an indigo wash over the surface, a soft glow at the inline end, glyph art and type. It draws a rounded block with no border and no status colour. art holds one icon, drawn in a 48px accent disc with an 8px translucent halo and hidden from assistive technology. The title is 16px bold, with one muted line of words under it, and the actions trail at the inline end. A feature banner is dismissible like any other, through dismissible and onDismiss.

svelte
<script lang="ts">
  import { Banner, Button } from '@lostgradient/cinder';
  import Sparkles from '@lucide/svelte/icons/sparkles';
</script>

<Banner variant="feature" title="Plan a night out with friends">
  Pick three bars and share one link; everyone votes before you go.
  {#snippet art()}
    <Sparkles aria-hidden="true" />
  {/snippet}
  {#snippet actions()}
    <Button variant="primary" size="sm" label="Start a plan" />
    <Button variant="ghost" size="sm" label="Not now" />
  {/snippet}
</Banner>

The banner reads its own width, not the viewport's: below 560px the actions drop under the words in the body column, and a button label never wraps. It is a region named by its title ("Announcement" when it has none), never a status or an alert, so nothing is announced as it appears.

When to show one:

  • At most one feature banner on a screen.
  • Never for an error or a system state. A status belongs in an info, success, warning or danger banner, or a connection preset.
  • Never alongside a hero that already carries an accent tone, such as a page header with the accent or night tone. One accent moment per screen is enough.
Live preview

Basic banner

Scheduled maintenance is planned for Sunday at 2:00 AM UTC.

02

When to use

Use when
  • Communicating a persistent page-level status the user can dismiss, such as a maintenance window or trial expiry.
  • Reporting that the browser is offline, the server is unreachable, a refresh failed or a restart is running, using a connection preset.
  • Pinning a non-urgent message above page content that should remain readable until acknowledged.
  • Announcing something new or inviting the person to try a feature, with the feature variant and its glyph art.
Avoid when
  • Announcing an urgent, time-sensitive message — use alert so assistive tech reads it immediately.
  • Highlighting an inline aside next to related prose — use callout instead.
03

Examples

Basic banner

Informational page-level banner with a dismiss button.

Feature banner

An announcement with glyph art, an indigo wash, a bold title, one muted line and trailing actions. It is a labelled region, not a status, and below 560px of its own width the actions drop under the words.

Neutral banner

The neutral variant for a page-wide note that is not a warning or a success: a stacked bold title over the sentence, with no status colour.

Every connection preset

The presets in the order the design lists them: offline, unreachable (with and without the changes sentence), stopped, out of date, refresh failed, restarting, reconnecting, restart failed and back online. Each fixes its tone, glyph, copy and actions, and none is dismissible.

Title and actions

A warning banner with a bold title, a line of detail and two secondary actions.

Unreachable preset

The server is down: the preset writes the sentence, the absolute as-of time, the countdown and Try again.

Banner variants

All four semantic variant styles — info, success, warning, and danger.

04

Props

Props for banner
Name
Type
Default
Description
variant 'neutral''info''success''warning''danger''feature' 'info' Visual + semantic variant. Default 'info'.
dismissible boolean true Whether the banner shows a dismiss (×) button. Default true. A banner with a preset is never dismissible: the connection and restart states cannot be hidden.
onDismiss () => void Called after the dismiss button is clicked. Use to persist state.
preset BannerPreset Applies a ready-made configuration: the tone, the accessible name, the words, a glyph and the actions of a connection or restart state (see {@link BannerPreset}). The preset overrides variant, makes the banner non-dismissible and, when children is omitted, writes its copy from dataUpdatedAt, subject, retryInSeconds, attempt and consequence. Passing children replaces the generated words and keeps the rest.
onRetry () => void Called when the Retry button is pressed. The button renders in the actions region, before actions, only when this is set. A preset that retries (offline, unreachable, stopped, refresh-failed, reconnecting) offers it only when this is set; restarting, restart-failed and back-online never offer it.
retryLabel text 'Try again' Label of the Retry button: "Try again", Cinder's one word for asking again (ErrorState's and LoadMore's too), with or without a preset, unless this says otherwise.
retryVariant 'primary' | 'secondary' How prominent the Retry button is. A preset makes it primary where Try again is the way back (stopped) and secondary everywhere else, so one action at a time looks primary.
dataUpdatedAt text When the data still on screen was last loaded. With a preset and no children the copy names it as an absolute time with its zone ("as of 10:44 AM CST"). Otherwise it adds a stale-data notice that reads "Showing data from" followed by a live relative time such as "2 minutes ago".
staleDataLabel text 'Showing data from' Text that precedes the relative time in the stale-data notice.
subject BannerPresetFacts['subject'] 'what loaded' What the page is showing, completing the preset's "Showing … as of …" sentence.
retryInSeconds BannerPresetFacts['retryInSeconds'] Seconds until the next automatic retry. A preset writes "Retrying in 4 s".
attempt BannerPresetFacts['attempt'] The attempt under way, counted from 1. A preset writes "(attempt 3 of 8)".
maxAttempts BannerPresetFacts['maxAttempts'] 8 How many attempts there are.
consequence BannerPresetFacts['consequence'] The sentence that says what is off while the banner shows, replacing the preset's own. Pass false to leave the sentence out.
timeZone BannerPresetFacts['timeZone'] IANA time zone of the preset's "as of" time. Defaults to the viewer's zone.
title text A bold lead for the banner, such as "1 change waits for a restart". With a preset it replaces the preset's lead and sits inline before the words; otherwise it sits on its own line above them.
titleLayout 'inline' | 'stacked' Where the title sits. A preset runs it inline, as the first words of its sentence; a banner without a preset puts it on its own line above the message.
icon snippet A glyph at the start of the banner, drawn decoratively (aria-hidden). The offline, unreachable and stopped presets supply their own connection glyph, and a success banner leads with a check-circle unless this draws another.
art snippet The glyph art of a feature banner: one icon, drawn in a 48px accent disc with an 8px translucent halo at the start of the banner. It is decorative (aria-hidden). Other variants ignore it.
sticky boolean false Keeps the banner at the top of its scroll container while the page scrolls under it.
stackActions boolean false Below 640px, puts the actions on a row of their own under the words, one above the next, each a full-width 44px button, for a banner whose buttons are bars on a phone. Without it the actions sit at the inline end of the message's row, or in a row under the words when the banner is narrower than 560px, at 44px.
onRestart () => void Called when the restart-failed preset's primary action, "Restart again", is pressed.
onOpenHealth () => void Called when the restart-failed preset's secondary action, "Open Health", is pressed.
healthHref text Makes "Open Health" a link to this address instead of a button.
children snippet Banner body content. Optional with a preset, which writes its own words.
actions snippet Optional trailing CTA region (e.g., "Renew now" button).