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.
Try it
Every variant
DefaultNegativePositiveWarningimport { Banner } from 'rost/components/banner/Banner'
<Banner
status="negative"
title="Your card was declined"
description="Update it before 3 December to keep sending invoices."
actions={<Link href="/settings/billing">Update the card</Link>}
/>
<Banner status="positive" title="Your bank is connected" onDismiss={() => setSeen(true)} /> src/components/banner/Banner.tsx
import type { HTMLAttributes, ReactNode } from 'react'
import './banner.css'
export type BannerStatus = 'default' | 'negative' | 'positive' | 'warning'
export interface BannerProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
/** Default has no icon: it's news, not a problem. */
readonly status?: BannerStatus
/** What happened, in a few words. */
readonly title: ReactNode
/** One line under it: what it means or what to do. */
readonly description?: ReactNode
/** A Link or two, to do something about it. */
readonly actions?: ReactNode
/** With it, a close button on the right. */
readonly onDismiss?: () => void
}
const b = 'rost-banner'
/**
* A notice across the top of a page or a section. `role="status"`, or
* `role="alert"` when it's Negative. Built from contracts/banner.contract.yaml.
*/
export function Banner({ status = 'default', title, description, actions, onDismiss, className, ...rest }: BannerProps) {
return (
<div role={status === 'negative' ? 'alert' : 'status'} className={[b, `${b}--status-${status}`, className].filter(Boolean).join(' ')} {...rest}>
<span className={`${b}__icon`} aria-hidden="true" />
<div className={`${b}__body`}>
<p className={`${b}__title`}>{title}</p>
{description != null && <p className={`${b}__description`}>{description}</p>}
{actions != null && <div className={`${b}__actions`}>{actions}</div>}
</div>
{onDismiss && (
<button type="button" className={`${b}__dismiss`} aria-label="Dismiss" onClick={onDismiss}>
<span className={`${b}__dismiss-glyph`} aria-hidden="true" />
</button>
)}
</div>
)
}
The source for everything on this page: contracts/banner.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: banner
name: Banner
kind: component
status: review
summary: "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."
category: feedback
related: [ inline-banner, toast, empty-state ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "780:54"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=780-54
extractedAt: "2026-11-30"
extractedBy: hand
frozenAt: "2026-11-30"
props:
status:
type: enum
values: [ Default, Negative, Positive, Warning ]
default: Default
notes: "Default has no icon: it's news, not a problem."
title: { type: slot, required: true, notes: "What happened, in a few words: Your card was declined." }
description: { type: slot, notes: "One line under it: what it means or what to do." }
actions: { type: slot, notes: "A Link or two under the description, to do something about it." }
onDismiss: { type: node, notes: "With it, a close button on the right. Leave it out for a notice that stays until the problem is fixed." }
states: [ Default, DismissHover, DismissFocus ]
stateSelectors:
DismissHover: ":has(.rost-banner__dismiss:hover)"
DismissFocus: ":has(.rost-banner__dismiss:focus-visible)"
elements:
root:
notes: "The strip: 16px in all round, 12px between its parts, Input's 12px corners. As wide as what it sits on top of."
styles:
display: { value: flex, assert: false }
align-items: { value: flex-start }
gap: { token: spacing/gap/small-medium, value: 12px }
padding: { token: spacing/gap/medium, value: 16px }
border-radius: { token: spacing/radius/medium, value: 12px }
width: { value: 560px, notes: "Just the size of the Figma frame. On a page it's as wide as the page's column." }
icon:
optional: true
notes: "InlineBanner's 20px glyph for the status, in its colour. Default has none."
styles:
display: { value: block, assert: false }
flex-shrink: { value: "0", assert: false }
width: { token: spacing/size/xsmall, value: 20px }
height: { token: spacing/size/xsmall, value: 20px }
body:
notes: "The words, filling the rest of the line."
styles:
display: { value: flex, assert: false }
flex-direction: { value: column, assert: false }
flex: { value: 1 1 0, assert: false }
min-width: { value: "0", assert: false }
gap: { token: spacing/gap/2xsmall, value: 4px }
title:
notes: "Paragraph type at medium weight, in the primary colour."
styles:
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: banner/title, value: "#ededed" }
description:
optional: true
notes: "Paragraph type, a step quieter."
styles:
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-weight: { token: typography/paragraph/font-weight/regular, value: "400" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
letter-spacing: { token: typography/paragraph/letter-spacing, value: 0px }
color: { token: banner/description, value: "#d3d9d5" }
actions:
optional: true
notes: "The links, in a row that wraps, 4px more below the words."
styles:
display: { value: flex, assert: false }
flex-wrap: { value: wrap, assert: false }
gap: { token: spacing/gap/medium, value: 16px }
padding-top: { token: spacing/gap/2xsmall, value: 4px }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
dismiss:
optional: true
notes: "A 24px round button with Input's clear glyph, on the right, at the top."
styles:
display: { value: flex, assert: false }
align-items: { value: center }
justify-content: { value: center }
flex-shrink: { value: "0", assert: false }
width: { token: spacing/size/small, value: 24px }
height: { token: spacing/size/small, value: 24px }
padding: { value: "0", assert: false }
border: { value: none, assert: false }
border-radius: { token: spacing/radius/full, value: 10000px }
background: { value: transparent, assert: false }
cursor: { value: pointer, assert: false }
dismiss-glyph:
notes: "Input's clear glyph, 16px, in the description's colour."
styles:
display: { value: block, assert: false }
width: { token: spacing/size/2xsmall, value: 16px }
height: { token: spacing/size/2xsmall, value: 16px }
mask: { value: url(./icon-close.svg) center / contain no-repeat, untokenised: The icon file itself. }
background: { token: banner/description, value: "#d3d9d5" }
variants:
- when: { status: Default }
figmaNode: "780:14"
elements:
root:
background: { token: banner/default/background, value: "#171717" }
icon:
display: { value: none, assert: false }
- when: { status: Negative }
figmaNode: "780:21"
elements:
root:
background: { token: banner/negative/background, value: "#48050c" }
icon:
mask: { value: url(./icon-alarm.svg) center / contain no-repeat, untokenised: "InlineBanner's glyph. The colour is the token." }
background: { token: banner/negative/icon, value: "#f2705f" }
- when: { status: Positive }
figmaNode: "780:33"
elements:
root:
background: { token: banner/positive/background, value: "#004c19" }
icon:
mask: { value: url(./icon-positive.svg) center / contain no-repeat, untokenised: "InlineBanner's glyph. The colour is the token." }
background: { token: banner/positive/icon, value: "#00d669" }
- when: { status: Warning }
figmaNode: "780:42"
elements:
root:
background: { token: banner/warning/background, value: "#492604" }
icon:
mask: { value: url(./icon-warning.svg) center / contain no-repeat, untokenised: "InlineBanner's glyph. The colour is the token." }
background: { token: banner/warning/icon, value: "#fda50d" }
- when: { state: DismissHover }
elements:
dismiss:
background: { token: banner/dismiss-hover, value: "#3a3a3a" }
- when: { state: DismissFocus }
elements:
dismiss:
outline: { value: "var(--spacing-outline-medium) solid var(--banner-focus-ring)", untokenised: "Composed from tokens: a 2px ring in banner/focus-ring." }
outline-offset: { value: "0", assert: false }
guidance:
status: proposed
use:
- title: Something about the whole page
text: "A card that was declined, a bank that needs connecting again, a tax year that closes on Friday. Above everything it's about."
show: "status=Negative"
avoid:
- title: About one field or one row
text: "Put an **InlineBanner** next to it instead, or the field's own error."
- title: Something that just happened
text: "A save, a send: that's a **Toast**, and it goes away by itself."
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."
Install
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
About one field or one row
Put an InlineBanner next to it instead, or the field's own error.
Something that just happened
A save, a send: that's a Toast, and it goes away by itself.
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 isrole="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
| Prop | Type | Values | Default |
|---|---|---|---|
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
-
gap12pxspacing/gap/small-medium -
padding16pxspacing/gap/medium -
border-radius12pxspacing/radius/medium -
width560pxno token yet
displayflex · align-itemsflex-start
icon
-
width20pxspacing/size/xsmall -
height20pxspacing/size/xsmall
displayblock · flex-shrink0
body
-
gap4pxspacing/gap/2xsmall
displayflex · flex-directioncolumn · flex1 1 0 · min-width0
title
-
font-family'General Sans Variable'font-family/base -
font-weight500typography/paragraph/font-weight/medium -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#edededbanner/title
description
-
font-family'General Sans Variable'font-family/base -
font-weight400typography/paragraph/font-weight/regular -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
letter-spacing0pxtypography/paragraph/letter-spacing -
color#d3d9d5banner/description
actions
-
gap16pxspacing/gap/medium -
padding-top4pxspacing/gap/2xsmall -
font-family'General Sans Variable'font-family/base -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height
displayflex · flex-wrapwrap
dismiss
-
width24pxspacing/size/small -
height24pxspacing/size/small -
border-radius10000pxspacing/radius/full
displayflex · align-itemscenter · justify-contentcenter · flex-shrink0 · padding0 · bordernone · backgroundtransparent · cursorpointer
dismiss-glyph
-
width16pxspacing/size/2xsmall -
height16pxspacing/size/2xsmall -
maskurl(./icon-close.svg) center / contain no-repeaton purpose: The icon file itself. -
background#d3d9d5banner/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
| Property | Negative | Positive | Warning |
|---|---|---|---|
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
| Property | Default | Negative | Positive | Warning |
|---|---|---|---|---|
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#3a3a3abanner/dismiss-hover
DismissFocus
-
dismiss.outlinevar(--spacing-outline-medium) solid var(--banner-focus-ring)on purpose: Composed from tokens: a 2px ring in banner/focus-ring. -
dismiss.outline-offset0Figma frame size
Default
-
icon.displaynonelayout