Vesyl UI

Sonner

Toast notifications for transient feedback — “Label purchased”, “Shipment cancelled”, and the like. Built on sonner, pre-styled with rich colors, lucide icons, and our theme tokens.

Two pieces: <Toaster />, the host that renders the stack, and toast(), the function you call to push a notification. The app mounts one <Toaster /> at the root (in WMS it lives in __root.tsx), then any component calls toast() — no context, no provider wiring at the call site.

Each demo below mounts its own <Toaster /> so the toast has somewhere to render. In a real app you do this once at the root, not per component.

Basic

Call toast() with a message string. It appears bottom-right, auto-dismisses, and stacks with any others.

Variants

toast.success, toast.error, toast.warning, and toast.info add a colored icon and accent. Reach for these to signal outcome — a purchased label is a success, a failed charge is an error. (toast.error is sticky in our wrapper: it stays until dismissed and shows a close button.)

Description and action

The second argument is an options object. description renders a secondary line; action adds a button — { label, onClick } — for a follow-up like copying a tracking number.

Promise / loading

toast.promise ties a single toast to an async task: it shows the loading message while the promise is pending, then swaps to success or error when it settles. Use it for purchases, cancellations, and other awaitable mutations. For a standalone spinner toast you can drive yourself, call toast.loading(...) and later toast.dismiss(id).

Reference

Toaster

The host component. Mount once near the app root. Extends sonner Toaster props — ours pre-sets richColors, themed style tokens, lucide icons, and a dismiss button, but every prop below can still be overridden.

PropTypeDefaultDescription
theme"light" | "dark" | "system"from next-themesColor scheme; defaults to the active app theme
position"top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right""bottom-right"Where the stack renders
richColorsbooleantrueTints success / error / warning / info toasts
closeButtonbooleanfalseShow a close button on every toast
expandbooleanfalseExpand the stack on hover instead of stacking
durationnumber4000Default auto-dismiss time in ms for all toasts
toastOptionsExternalToastDefault options merged into every toast

toast()

The trigger function, re-exported from sonner with our overrides. Call toast(message, options?), or one of the variant methods. Returns the toast id.

MethodSignatureDescription
toast(message, options?) => idDefault neutral toast
toast.success(message, options?) => idSuccess variant (green, check icon)
toast.error(message, options?) => idError variant — sticky in our wrapper (no auto-dismiss, close button)
toast.warning(message, options?) => idWarning variant (amber, triangle icon)
toast.info(message, options?) => idInfo variant (blue, info icon)
toast.loading(message, options?) => idSpinner toast; dismiss it yourself with the returned id
toast.promise(promise, { loading, success, error }) => idBinds one toast to an async task’s lifecycle
toast.message(message, options?) => idExplicit neutral toast (alias of the default call)
toast.dismiss(id?) => voidDismiss a specific toast, or all when called with no id

Options (second argument)

The options object (ExternalToast) shared by all toast methods. Common fields:

OptionTypeDescription
descriptionReactNodeSecondary line under the message
action{ label, onClick }A button rendered in the toast for a follow-up action
durationnumberAuto-dismiss time in ms (Infinity to keep it open)
closeButtonbooleanShow a close button on this toast
idstring | numberReuse an id to update an existing toast in place
onDismiss(toast) => voidFires when the toast is dismissed
onAutoClose(toast) => voidFires when the toast auto-closes after its duration