uimaxxer

Toast

A promise toast turns from loading into done in place: the spinner's arc bends into the check, and its clock stops on the time it took. Swipe any toast back the way it came.

npx shadcn@latest add https://uimaxxer.com/r/toast.json
PasskeysFix the duplicate Stripe charge

Usage

import { Toaster, toast } from "@/components/ui/toast"

<Toaster />

toast("Archived run 1187", { action: { label: "Undo", onClick: restore } })
toast.promise(merge(482), { loading: "Merging #482", success: "Merged #482 into main", error: "Merge failed" })

Props

PropTypeDefaultWhat it does
toast(title, options)functionShows a toast and returns its id. Options: description, action, duration, type, id.
toast.success / toast.errorfunctionSame, with a drawn check or a warning glyph.
toast.promise(p, messages)functionOne toast that morphs from loading to success or error in place.
toast.dismiss(id?)functionDismiss one, or all with no id.
Toaster position"bottom-right" | "bottom-center" | … | "top-left""bottom-right"Toasts enter from that edge and swipe back toward it.
Toaster durationnumber4000Time on screen in ms. Paused while hovered, focused or the tab is hidden.
Toaster visiblenumber3How many show in the deck.
Toaster inlinebooleanPosition inside the nearest positioned parent instead of the viewport.
Toaster expandbooleanfalseKeep the deck fanned out instead of stacked until hover.
Toaster widthnumber356Toast width in px.

Keyboard

Alt+T
Focus the newest toast
Tab
Move through toasts and their actions
Esc
Dismiss the focused toast

Accessibility

  • A labelled region with a polite live list; errors use role=alert.
  • Timers pause while the deck is hovered or focused, so nobody has to race a toast.
  • Swiping is optional: Esc dismisses and every action is a real button.