toast
a short note in the corner of the window: what just happened, one thing you can do about it, then it goes.
bunx --bun shadcn@latest add @mk/toastin both modes
three toasts, the newest in front. the two behind peek 12 px above it, and hovering the stack spreads them 12 px apart. the stack moves by whole pixels and never scales, so the screen on its contact edge keeps its 1 px cells.
each type prints its status glyph in its own ink: success the tick, info the i, warning the pause, error the cross. loading shows the i.
draws where a floating layer meets the page, under its soft lift
try it
these go to a real toaster in the corner of the window, in the page’s mode. each one leaves after 5 seconds; hover or focus the stack to hold it. loading waits on a promise, then turns into a success.
parts
base-nova’s toast, on base ui’s toast manager. put <Toaster /> near the root once, then call toast from anywhere.
toast.add- shows a toast and returns its id. it takes
title,description,typeandactionPropsfor its one action;typepicks the glyph. toast.promise- one toast that follows a promise, from loading to success or error.
toast.update- changes a toast in place, by its id.
toast.close- closes one toast by its id, or every toast with no id.
Toaster- the stack in the window’s corner. pass
toastManagerto give it a manager of its own. Toast- the parts the stack is built from, with
ToastContent,ToastTitle,ToastDescription,ToastActionandToastClose, for a stack of your own underToastProviderandToastViewport. ToastList- the provider’s toasts as
Toasterprints them. put it in a viewport of your own to show the stack somewhere else, as this page does above.actionstakes each toast and returns its action row, so a toast can carry more than its one action: the front toast above adds a ghostundo, named in itsdata. by default the row holds the one action. ToastIcon- the status glyph for a toast’s
type, for a toast you build from the parts.