Skip to content

Toast

Get Ritla UI

Confirms what just happened without stopping anyone. Add one action, like Undo or Retry, and it becomes a snackbar.

Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add toast

    Also works with shadcn: npx shadcn@latest add @ritla/toast

  2. Dependencies it brings

    @base-ui/react@phosphor-icons/react

  3. Or copy by hand

    Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.

Usage

toast.tsx
import { Toaster, toast } from "@/components/ui/toast";// Once, in the root layout:<Toaster /> // Anywhere:toast({ message: "Card removed", action: { label: "Undo", onClick: restoreCard } });

Examples

Undo

The card goes at once, and Undo brings it back. A toast with an action stays until it's used or dismissed, so the chance isn't lost.

EnglishMirroredArabic
LTR →

Types

Toast renders the look alone, without a timer. Default for most confirmations; Success, Error and Warning when the outcome matters; Brand rarely. Warning keeps its light colors in dark mode.

EnglishMirroredArabic
LTR →

API reference

toast()

PropTypeDefaultDescription
messagestringNoneFigma's Message: what happened, in one line; it's what screen readers announce.
type"default" | "brand" | "success" | "error" | "warning""default"Figma's Type. Errors are announced urgently.
action{ label: string; onClick: () => void }NoneFigma's Show action: one action; it keeps the toast on screen.
iconIconComponent | nullNoneFigma's Leading icon; null hides it.
dismissbooleantrueFigma's Show dismiss.
timeoutnumber5000 / 0Milliseconds; 0 (stays) when there's an action.
toast.dismiss(id?)functionNoneCloses one toast, or all of them.

Toaster

PropTypeDefaultDescription
offsetstringNoneExtra space below the toasts on phones, to clear a navigation bar.

Toast

PropTypeDefaultDescription
message / type / iconReactNode / ToastType / IconComponent | nullNoneThe look alone, for static use.
action / dismissReactNodeNoneToastActionButton and ToastDismissButton.

Accessibility

Keyboard

Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.

KeyAction
TabTo the action and the dismiss button; focus never jumps to a toast on its own.

ARIA

  • Toasts are announced politely (status), errors urgently (alert), and focus stays where it is.
  • The timer pauses on hover and focus, and a toast with an action never disappears on its own.
  • The dismiss button has a name (Dismiss); an error isn't shown by color alone: the message says it.

Arabic and RTL notes

Mirrors

  • The icon and message sit on the right; the action and dismiss button on the left.
  • On larger screens they appear at the bottom inline end: the bottom left.
  • Each toast takes the direction and language of where it was triggered.

Does not mirror

  • Toasts slide in and swipe away vertically in both languages.
Numerals
Amounts in the message follow the numerals setting and read left to right.
Arabic typography
The message is body-14 Medium, one line; the toast is at least 48px tall.
Mixed-direction text
Keep the Arabic message as short as the English: “أُزيلت البطاقة”.

Checks it passes

The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.

  • R012Untranslated attribute text (placeholder, alt, title, aria-label, button value)
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space
  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)