component
Toast
A short message that something happened, with one thing you can do about it. Badge's dot, the words and a Borderless Button, on a floating plate.
Try it
Every variant
Default · Not dismissiblePositive · Not dismissibleWarning · Not dismissibleNegative · Not dismissibleDefault · Dismissibleimport { Toast } from 'rost/components/toast/Toast'
<Toast tone="positive" action={<Button variant="borderless" onClick={undo}>Undo</Button>}>
Invoice sent
</Toast> src/components/toast/Toast.tsx
import type { HTMLAttributes, ReactNode } from 'react'
import { Badge } from '../badge/Badge'
import { IconButton } from '../icon-button/IconButton'
import './toast.css'
export type ToastTone = 'default' | 'positive' | 'warning' | 'negative'
export interface ToastProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
readonly tone?: ToastTone
/** What happened, in one short line. */
readonly children: ReactNode
/** One Borderless Button, like Undo. */
readonly action?: ReactNode
/** Shows a close button that calls this. */
readonly onClose?: () => void
}
const b = 'rost-toast'
/**
* A short message that something happened, with one thing to do about it.
* Read out by screen readers when it appears: at once when it's negative.
* The app decides where it sits and how long it stays. Built from
* contracts/toast.contract.yaml.
*/
export function Toast({ tone = 'default', children, action, onClose, className, ...rest }: ToastProps) {
return (
<div role={tone === 'negative' ? 'alert' : 'status'} className={[b, `${b}--tone-${tone}`, onClose && `${b}--dismissible`, className].filter(Boolean).join(' ')} {...rest}>
<Badge className={`${b}__badge`} status={tone} size="small" />
<span className={`${b}__message`}>{children}</span>
{action != null && <span className={`${b}__action`}>{action}</span>}
{onClose && <IconButton className={`${b}__close`} variant="tertiary" aria-label="Dismiss" icon={<span className={`${b}__close-glyph`} />} onClick={onClose} />}
</div>
)
}
The source for everything on this page: contracts/toast.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: toast
name: Toast
kind: component
status: review
summary: A short message that something happened, with one thing you can do about it. Badge's dot, the words and a Borderless Button, on a floating plate.
category: feedback
related: [ inline-banner, badge, button, dialog ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "738:85"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=738-85
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
tone:
type: enum
values: [ default, positive, warning, negative ]
default: default
notes: "The dot's colour, Badge's statuses. `negative` is read out at once (`role=\"alert\"`), the others when the screen reader has a moment."
children: { type: slot, required: true, notes: "What happened, in one short line." }
action: { type: slot, notes: "One Borderless Button, like Undo or View. Leave it out when there's nothing to do." }
dismissible: { type: boolean, default: false, notes: "A close button at the end. In React it's there when you pass `onClose`." }
elements:
root:
notes: "A row: the dot, the words, the action. 56px tall, Input's height, so a Borderless Button fits with 4px around it."
styles:
display: { value: inline-flex, assert: false }
align-items: { value: center }
gap: { token: spacing/gap/small, value: 8px }
height: { token: spacing/size/large, value: 56px }
padding-left: { token: spacing/gap/small-medium, value: 12px }
padding-right: { token: spacing/gap/2xsmall, value: 4px }
border-radius: { token: spacing/radius/medium, value: 12px }
background: { token: toast/background, value: "#171717" }
outline-style: { value: solid, assert: false }
outline-width: { token: spacing/outline/small, value: 1px }
outline-offset: { value: "calc(-1 * var(--spacing-outline-small))", untokenised: "Composed from a token: the edge sits inside the plate." }
outline-color: { token: toast/edge, value: "#3a3a3a" }
box-shadow: { token: shadow/floating, value: "0px 16px 24px 0px rgba(0, 0, 0, 0.16)", notes: "The kit's only drop shadow, for things that float above the page." }
badge:
notes: "A small Badge, as it is: the 24px frame with the dot in the tone's colour."
styles:
flex-shrink: { value: "0", assert: false }
message:
notes: "Paragraph type in the main text colour, 8px clear of the action or the edge."
styles:
padding-right: { token: spacing/gap/small, value: 8px }
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: toast/message, value: "#ededed" }
white-space: { value: nowrap, assert: false }
action:
notes: "A Button with `variant=\"Borderless\"`, as it is."
styles:
flex-shrink: { value: "0", assert: false }
close:
optional: true
notes: "An IconButton with `variant=\"tertiary\"`, as it is: 48px, so it sits in the 56px plate with 4px around it, like the action."
styles:
flex-shrink: { value: "0", assert: false }
close-glyph:
optional: true
notes: "Input's clear icon, 16px, in the IconButton's own icon colour."
styles:
display: { value: block, assert: false }
width: { token: spacing/size/2xsmall, value: 16px }
height: { token: spacing/size/2xsmall, value: 16px }
background: { value: currentColor }
mask: { value: url(./icon-clear.svg) center / contain no-repeat, untokenised: The icon file itself. }
variants:
- when: { tone: default, dismissible: false }
figmaNode: "738:52"
- when: { tone: positive, dismissible: false }
figmaNode: "738:60"
- when: { tone: warning, dismissible: false }
figmaNode: "738:68"
- when: { tone: negative, dismissible: false }
figmaNode: "738:76"
- when: { tone: default, dismissible: true }
figmaNode: "741:69"
guidance:
status: proposed
use:
- title: Something happened
text: "Saved, sent, paid, deleted. Say it in a few words, and offer Undo when you can."
show: tone=positive, dismissible=False
- title: Something failed in the background
text: "A sync that didn't go through. `negative`, with Retry."
show: tone=negative, dismissible=False
avoid:
- title: Something to decide
text: "If they have to answer, that's **Dialog**."
- title: A problem with the screen in front of them
text: "An error in a form belongs next to the field, or in an **InlineBanner** at the top."
behaviour: |-
A floating plate with Badge's dot, the message and at most one Borderless Button. Toast draws it; the app decides where it sits (bottom centre is a good default) and for how long. Five seconds is enough for a line; keep it up while a pointer is over it. With `onClose` it gets a close button at the end, for a message that should stay until it's read. Several at once go in a **ToastStack**, newest at the bottom, 8px apart.
accessibility:
element: "A `<div role=\"status\">`, or `role=\"alert\"` when it's `negative`, so screen readers say it without moving focus."
name: "The message is what's read. Don't rely on the dot's colour: the words say whether it worked."
keyboard: "The action is a Button and takes Tab like any other. Don't make it the only way to do the thing: Undo should be in the page too."
colour: "The message is 14:1 on the plate in dark."
content: "Past tense, short, no full stop: \"Invoice sent\", \"Couldn't sync, check your connection\"."
Install
npx github:Runceanu/rost add toast It lands in src/rost/toast/, with what it needs and its contract. Install has the rest.
When to use
Something happened
Saved, sent, paid, deleted. Say it in a few words, and offer Undo when you can.
Something failed in the background
A sync that didn't go through.
negative, with Retry.
When not to use
Something to decide
If they have to answer, that's Dialog.
A problem with the screen in front of them
An error in a form belongs next to the field, or in an InlineBanner at the top.
Behaviour
A floating plate with Badge's dot, the message and at most one Borderless Button. Toast draws it; the app decides where it sits (bottom centre is a good default) and for how long. Five seconds is enough for a line; keep it up while a pointer is over it. With onClose it gets a close button at the end, for a message that should stay until it's read. Several at once go in a ToastStack, newest at the bottom, 8px apart.
Accessibility
- Element
A
<div role="status">, orrole="alert"when it'snegative, so screen readers say it without moving focus. - Name
The message is what's read. Don't rely on the dot's colour: the words say whether it worked.
- Keyboard
The action is a Button and takes Tab like any other. Don't make it the only way to do the thing: Undo should be in the page too.
- Colour
The message is 14:1 on the plate in dark.
Content
Past tense, short, no full stop: "Invoice sent", "Couldn't sync, check your connection".
Props
| Prop | Type | Values | Default |
|---|---|---|---|
tone | enum | default · positive · warning · negative | default |
children | slot | | |
action | slot | | |
dismissible | boolean | | false |
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
-
gap8pxspacing/gap/small -
height56pxspacing/size/large -
padding-left12pxspacing/gap/small-medium -
padding-right4pxspacing/gap/2xsmall -
border-radius12pxspacing/radius/medium -
background#171717toast/background -
outline-width1pxspacing/outline/small -
outline-offsetcalc(-1 * var(--spacing-outline-small))on purpose: Composed from a token: the edge sits inside the plate. -
outline-color#3a3a3atoast/edge -
box-shadow0px 16px 24px 0px rgba(0, 0, 0, 0.16)shadow/floating
displayinline-flex · align-itemscenter · outline-stylesolid
badge
flex-shrink0
message
-
padding-right8pxspacing/gap/small -
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#edededtoast/message
white-spacenowrap
action
flex-shrink0
close
flex-shrink0
close-glyph
-
width16pxspacing/size/2xsmall -
height16pxspacing/size/2xsmall -
backgroundcurrentColorno token yet -
maskurl(./icon-clear.svg) center / contain no-repeaton purpose: The icon file itself.
displayblock
Part of Toast
ToastStack
Where toasts go when there's more than one. A column, newest at the bottom, fixed to the bottom of the window or in place.
Inlineimport { ToastStack } from 'rost/components/toast-stack/ToastStack'
<ToastStack>
{toasts.map((t) => <Toast key={t.id} tone={t.tone} onClose={() => dismiss(t.id)}>{t.text}</Toast>)}
</ToastStack> src/components/toast-stack/ToastStack.tsx
import type { HTMLAttributes, ReactNode } from 'react'
import './toast-stack.css'
export interface ToastStackProps extends HTMLAttributes<HTMLDivElement> {
/** `bottom` floats over the page; `inline` stays where it's put. */
readonly placement?: 'bottom' | 'inline'
/** The Toasts, oldest first. */
readonly children?: ReactNode
}
const b = 'rost-toast-stack'
/**
* Where toasts go when there's more than one: a column, newest at the
* bottom. It only lays them out; which ones show and for how long is the
* app's. Built from contracts/toast-stack.contract.yaml.
*/
export function ToastStack({ placement = 'bottom', children, className, ...rest }: ToastStackProps) {
return <div role="region" aria-label="Notifications" className={[b, `${b}--placement-${placement}`, className].filter(Boolean).join(' ')} {...rest}>{children}</div>
}
The source for everything on this page: contracts/toast-stack.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: toast-stack
name: ToastStack
kind: component
status: review
partOf: toast
summary: Where toasts go when there's more than one. A column, newest at the bottom, fixed to the bottom of the window or in place.
category: feedback
related: [ toast ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "741:102"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=741-102
extractedAt: "2026-11-16"
extractedBy: hand
frozenAt: "2026-11-16"
props:
placement:
type: enum
values: [ bottom, inline ]
default: bottom
notes: "`bottom` floats over the page, centred, 24px from the bottom. `inline` stays where it's put, for a panel or a preview."
children: { type: slot, notes: "The Toasts, oldest first." }
elements:
root:
notes: "A `<div>` labelled Notifications. It lays the toasts out in a column, centred, 8px apart. The toasts say themselves what they are."
styles:
display: { value: flex, assert: false }
flex-direction: { value: column, assert: false }
align-items: { value: center }
gap: { token: spacing/gap/small, value: 8px }
variants:
- when: { placement: bottom }
elements:
root:
position: { value: fixed, assert: false }
bottom: { token: spacing/gap/large, value: 24px }
left: { value: 50%, assert: false }
transform: { value: translateX(-50%), assert: false, notes: "Centres the column on the window." }
z-index: { value: "100", assert: false, notes: "Over the page's own content. A modal Dialog still covers it: the browser puts that in a layer above everything." }
- when: { placement: inline }
figmaNode: "741:84"
elements:
root:
position: { value: static, assert: false }
guidance:
status: proposed
use:
- title: More than one at a time
text: "Two things finished close together. The newer one goes at the bottom, nearest where the eye already is."
show: placement=inline
avoid:
- title: A list of everything
text: "A history of what happened belongs on a page, not in a stack that keeps growing. Three is plenty; let the oldest go."
behaviour: |-
It only lays toasts out. Which ones show and for how long is the app's: take each away after a few seconds, or when it's closed. At the bottom of the window it floats, centred, 24px up.
accessibility:
element: "A `<div role=\"region\" aria-label=\"Notifications\">`, so someone can find it from the landmarks. Each Toast announces itself."
Install
npx github:Runceanu/rost add toast-stack It lands in src/rost/toast-stack/, with what it needs and its contract. Install has the rest.
When to use
More than one at a time
Two things finished close together. The newer one goes at the bottom, nearest where the eye already is.
When not to use
A list of everything
A history of what happened belongs on a page, not in a stack that keeps growing. Three is plenty; let the oldest go.
Behaviour
It only lays toasts out. Which ones show and for how long is the app's: take each away after a few seconds, or when it's closed. At the bottom of the window it floats, centred, 24px up.
Accessibility
- Element
A
<div role="region" aria-label="Notifications">, so someone can find it from the landmarks. Each Toast announces itself.
Props
| Prop | Type | Values | Default |
|---|---|---|---|
placement | enum | bottom · inline | bottom |
children | slot | | |
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
-
gap8pxspacing/gap/small
displayflex · flex-directioncolumn · align-itemscenter
Changes by variant
2 variants. Each table is what one thing changes with: a column per placement, a row per property. Where every row starts with the same token path, it's written once, under the property.
Follows placement
| Property | Bottom | Inline |
|---|---|---|
root.position | fixed | static |
Only in some variants
These don't change: they're just set in some variants and not others.
Bottom
-
root.bottom24pxspacing/gap/large -
root.left50%Figma frame size -
root.transformtranslateX(-50%)Figma frame size -
root.z-index100Figma frame size