Rost

← All components

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.

In code Contract: review Guidance: proposed Contract on GitHub Figma 738:85 As markdown

Try it

Every variant

Invoice sent
Default · Not dismissible
Invoice sent
Positive · Not dismissible
Invoice sent
Warning · Not dismissible
Negative · Not dismissible
Your bank sync is back on
Default · Dismissible

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

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".

Props

PropTypeValuesDefault
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

  • gap 8px spacing/gap/small
  • height 56px spacing/size/large
  • padding-left 12px spacing/gap/small-medium
  • padding-right 4px spacing/gap/2xsmall
  • border-radius 12px spacing/radius/medium
  • background #171717 toast/background
  • outline-width 1px spacing/outline/small
  • outline-offset calc(-1 * var(--spacing-outline-small)) on purpose: Composed from a token: the edge sits inside the plate.
  • outline-color #3a3a3a toast/edge
  • box-shadow 0px 16px 24px 0px rgba(0, 0, 0, 0.16) shadow/floating

displayinline-flex · align-itemscenter · outline-stylesolid

badge

flex-shrink0

message

  • padding-right 8px spacing/gap/small
  • 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 #ededed toast/message

white-spacenowrap

action

flex-shrink0

close

flex-shrink0

close-glyph

  • width 16px spacing/size/2xsmall
  • height 16px spacing/size/2xsmall
  • background currentColor no token yet
  • mask url(./icon-clear.svg) center / contain no-repeat on 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.

In code Contract: review Guidance: proposed Contract on GitHub Figma 741:102 As markdown
Invoice sent
Inline

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

PropTypeValuesDefault
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

  • gap 8px spacing/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

PropertyBottomInline
root.position fixed static

Only in some variants

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

Bottom

  • root.bottom 24px spacing/gap/large
  • root.left 50% Figma frame size
  • root.transform translateX(-50%) Figma frame size
  • root.z-index 100 Figma frame size