Pular para o conteúdo

Banners

components specs/components/banners.kmd

Persistent informational bar at the top of a content region — carries a message and 1-2 actions. Material parity (`/components/banners`). Distinguished from snackbars (transient) and dialogs (modal); banners stay until dismissed and never block interaction.

Quando esta spec se aplica

Triggers primários

Todos os triggers

Corpo da especificação

Spec — Banners

Facet Visual of Koder Design. Material parity: https://m3.material.io/components/banners.

Where they fit

ComponentModalityPersistence
BannerNon-modalPersistent until user dismisses / acts
SnackbarNon-modalTransient (4-10 s)
DialogModalPersistent until user dismisses

Pick banner when: information requires action OR awareness over multiple page interactions, but does NOT need to block the user.

Anatomy

┌────────────────────────────────────────────────────────┐
│  ⓘ  Your subscription expires in 3 days.               │
│      Renew now to keep access.                         │
│                                  [Renew]   [Dismiss]   │
└────────────────────────────────────────────────────────┘
   ↑   ↑                              ↑         ↑
 icon  message                      action1   action2
  • Height: 54 px (single line) / 90 px (two lines) / auto
  • Padding: 16 px vertical, 24 px horizontal
  • Icon: 24 px, optional, leading
  • Message: body-medium (14/20, weight 400)
  • Actions: text buttons, trailing
  • Border: 1 px bottom outline-variant
  • Background: surface-container-low

R1 — Variants by tone

ToneUseIconBackground
InfoGeneral announcementinfo (ⓘ)surface-container-low
WarningAction needed soonwarning (⚠)warning-container
ErrorAction needed now / degraded serviceerror (✕)error-container
Success / promoPositive announcementcheck (✓)success-container (extended)

Color alone never carries meaning — always pair tone with icon + text.

R2 — Action rules

  • 0 actions: dismiss-only banner; tap × at end OR auto-show dismiss after read
  • 1 action: action + dismiss button (× icon at end)
  • 2 actions: primary + secondary text buttons; no separate × (secondary serves as dismiss when labeled "Dismiss")

Maximum 2 visible actions. Don't put overflow menu in a banner.

R3 — Placement

PlacementWhen
Top of page content (default)One banner per page
Top of sectionOne banner scoped to a section
Inside list / formInline banner about a specific item

Never stack multiple banners. If multiple announcements pending, show the highest-priority one first; queue the rest after dismissal.

App bar sits ABOVE banner — banner anchors below the top app bar.

R4 — Persistence and state

  • Banner stays visible across scroll (does not stick to viewport; scrolls with content)
  • Dismissal is REMEMBERED per user + per banner ID — don't re-show the same dismissed banner unless conditions change
  • For "cookie consent" or "system upgrade" type banners, document re-show conditions explicitly

R5 — Animation

  • Appear: slide-down from top edge (motion-medium, ~250 ms)
  • Dismiss: fade-out + slide-up (motion-fast, ~150 ms)
  • Content below shifts smoothly when banner appears / disappears (no abrupt layout jump)
  • Reduced motion: instant show / hide

R6 — Accessibility

  • role="status" (info) or role="alert" (warning/error)
  • aria-live="polite" (status) / assertive (alert)
  • Action buttons have full labels (not "Click here")
  • Dismiss × button: aria-label="Dismiss banner"
  • Keyboard: Tab into action buttons → dismiss button; Esc dismisses (when allowed by banner type)
  • Icon is decorative if message conveys tone in words — aria-hidden

R7 — Mobile responsiveness

WidthBehavior
≥ 600 dpSingle row, actions trailing
< 600 dpTwo rows: message on top, actions on second row (left-aligned)

Truncate to 2 lines max on Compact width; expand to fit when actions move to a separate row.

R8 — Density

DensityPaddingHeight (single line)
Compact12 px / 20 px48 px
Default16 px / 24 px54 px
Comfortable20 px / 28 px64 px

R9 — Per-preset variation

PresetVisual
material3Tonal background by tone, no border, 24 px radius corners on rounded variant
material2Sharp corners, 1 px hairline border
ios_cupertinoTop-anchored, slight translucency, dismiss as swipe-up gesture
gnomeInfoBar style — flat tonal, 6 px border-radius
windows_11Mica backdrop tint, accent color border-left
brutalistSolid color block, 4 px thick border, no rounded corners
terminal_classicBorder-style box ┌── INFO ───┐ ... └──[OK]─┘

R10 — Forbidden patterns

  • ❌ Stacking multiple banners on one page
  • ❌ Banner over modal (banner is non-modal; modal already blocks)
  • ❌ Auto-dismissing banner with a timer (use snackbar instead)
  • ❌ More than 2 actions
  • ❌ Putting form inputs / interactive controls inside banner body
  • ❌ Showing the same dismissed banner without user-visible state change
  • ❌ Color-only tone signal (always pair with icon + words)
  • ❌ Sticking banner to viewport on scroll (annoying; use snackbar if must stay visible)
  • themes/color-roles.kmd — tonal container tokens
  • themes/elevation.kmd — banner sits at 0 dp (within surface)
  • components/snackbars.kmd — transient sibling
  • components/dialogs.kmd — modal sibling
  • foundations/elements.kmd — Container + Marker families

Referências