Rost

← All components

component

Banner

A notice across the top of a page or a section: what happened, a line on what to do, and maybe a way to do it. In four statuses, on a tint of the status's colour.

In code Contract: review Guidance: proposed Contract on GitHub Figma 780:54 As markdown
npx github:Runceanu/rost add banner

It lands in src/rost/banner/, with what it needs and its contract. Install has the rest.

When to use

  • Something about the whole page

    A card that was declined, a bank that needs connecting again, a tax year that closes on Friday. Above everything it's about.

When not to use

Behaviour

It stays until it's dismissed or the thing it's about is fixed. With onDismiss it has a close button; without it, it can't be closed, which is right for a problem that's still there. Dismissing it is the app's to remember.

Accessibility

  • Element

    role="status", so a screen reader reads it when it appears, after what it's saying; Negative is role="alert", read straight away. The icon is decoration: the title says what it is.

  • Name

    The close button says Dismiss.

  • Keyboard

    Tab reaches the links, then the close button.

  • Focus

    Each link's own ring; the close button's 2px ring on :focus-visible.

  • Colour

    The words are 11:1 or better on every tint, in both themes.

Content

A title that says what happened, not the status: Your card was declined, not Error. The description says what to do.

Props

PropTypeValuesDefault
status enum Default · Negative · Positive · Warning Default
title slot
description slot
actions slot
onDismiss node

States: Default, DismissHover, DismissFocus.

Values

Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.

Never changes

root

  • gap 12px spacing/gap/small-medium
  • padding 16px spacing/gap/medium
  • border-radius 12px spacing/radius/medium
  • width 560px no token yet

displayflex · align-itemsflex-start

icon

  • width 20px spacing/size/xsmall
  • height 20px spacing/size/xsmall

displayblock · flex-shrink0

body

  • gap 4px spacing/gap/2xsmall

displayflex · flex-directioncolumn · flex1 1 0 · min-width0

title

  • font-family 'General Sans Variable' font-family/base
  • font-weight 500 typography/paragraph/font-weight/medium
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • letter-spacing 0px typography/paragraph/letter-spacing
  • color #ededed banner/title

description

  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/paragraph/font-weight/regular
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • letter-spacing 0px typography/paragraph/letter-spacing
  • color #d3d9d5 banner/description

actions

  • gap 16px spacing/gap/medium
  • padding-top 4px spacing/gap/2xsmall
  • font-family 'General Sans Variable' font-family/base
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height

displayflex · flex-wrapwrap

dismiss

  • width 24px spacing/size/small
  • height 24px spacing/size/small
  • border-radius 10000px spacing/radius/full

displayflex · align-itemscenter · justify-contentcenter · flex-shrink0 · padding0 · bordernone · backgroundtransparent · cursorpointer

dismiss-glyph

  • width 16px spacing/size/2xsmall
  • height 16px spacing/size/2xsmall
  • mask url(./icon-close.svg) center / contain no-repeat on purpose: The icon file itself.
  • background #d3d9d5 banner/description

displayblock

Changes by variant

6 variants. Each table is what one thing changes with: a column per status, a row per property. Where every row starts with the same token path, it's written once, under the property.

Follows status

In 3 variants

PropertyNegativePositiveWarning
icon.backgroundbanner/… negative/icon #f2705f positive/icon #00d669 warning/icon #fda50d
icon.mask url(./icon-alarm.svg) center / contain no-repeat url(./icon-positive.svg) center / contain no-repeat url(./icon-warning.svg) center / contain no-repeat

In 4 variants

PropertyDefaultNegativePositiveWarning
root.backgroundbanner/… default/background #171717 negative/background #48050c positive/background #004c19 warning/background #492604

Only in some variants

These don't change: they're just set in some variants and not others.

DismissHover

  • dismiss.background #3a3a3a banner/dismiss-hover

DismissFocus

  • dismiss.outline var(--spacing-outline-medium) solid var(--banner-focus-ring) on purpose: Composed from tokens: a 2px ring in banner/focus-ring.
  • dismiss.outline-offset 0 Figma frame size

Default

  • icon.display none layout