Appica UIUI 1.0.0

Toast

A brief, dismissible notification that stacks in a corner of the screen.

Usage

Mount ToastProvider near the root of your app and render Toaster once inside it — that's the portal-anchored viewport every toast appears in. Then call useToastManager().add(...) from anywhere below the provider to fire one.

A toast is imperative: you describe it as data (title, description, an optional icon, an action button) and the Toaster renders, stacks, and animates it for you. Each one auto-dismisses after timeout (5s by default), can be swiped away, and exposes a close button. Toaster accepts a position to pin the stack to any corner or edge.

Examples

Default

Fire a toast with a title and description from a useToastManager().add(...) call. It slides in, waits, and dismisses itself.

With an icon

Pass a leading icon through the toast's typed data (useToastManager<{ icon?: ReactNode }>()). A filled, color-matched glyph signals success, error, or another state at a glance while the surface stays neutral.

With a thumbnail

For more prominence, wrap the icon in a Thumbnail (size="sm") with an icon-* variant — a tinted badge that pairs a soft background with the state color.

With an action

Add actionProps for an inline button — an "Undo", "Retry", or "View". Its onClick runs your handler; here it fires a follow-up toast.

Promise

Hand toast.promise(...) a promise plus loading / success / error states and it swaps the content as the promise settles — ideal for saves and uploads. (This demo fails at random to show both outcomes.)

Positions

Set position on Toaster to anchor the stack: any of the six corners and edges. Toasts swipe toward their nearest edge to dismiss.

Timeout & progress

timeout controls how long a toast lingers — pass timeout: 0 for a sticky toast that stays until dismissed. Progress is opt-in: set progress on the Toaster to draw a thin bar counting down on any auto-dismissing toast (including ones that use the default 5s). When you do, set timeout on the Toaster to match a custom ToastProvider timeout so the bar's duration lines up.

RTL

Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior follows the same direction.

Under RTL the toast's layout mirrors — the icon leads from the right, the close button moves to the left — and the countdown progress bar drains in the reading direction. For setup details and caveats, see the RTL guide.

API reference

Toast wraps Base UI's Toast. Each part forwards its remaining props to the matching Base UI primitive and carries a data-slot for styling — the tables below list the Appica additions and the most common props.

ToastProvider

Holds the toast queue and timing config. Wrap your app (or the subtree that fires toasts) in it. Renders no DOM of its own.

Toaster

The viewport: portals to the body and renders the live stack. Render exactly one per provider.

Toaster reads the live toasts from the manager and renders each as a Toast with its title, description, optional data.icon, and actionProps.

useToastManager

A hook returning the manager used to create and control toasts. Must be called under a ToastProvider.

createToastManager() returns the same control surface (minus the reactive toasts) for firing toasts outside the React tree — pass it to ToastProvider's toastManager.

add / update options

Toast and its parts

Toaster assembles these for you, but they're exported for manual composition (custom layouts, extra parts): Toast, ToastIcon, ToastTitle, ToastDescription, ToastActions, ToastAction, ToastClose, ToastProgress, and the lower-level ToastViewport / ToastPortal.

Accessibility

  • The Toaster viewport is a labelled landmark (an aria-live region); press F6 to jump to it from anywhere on the page.
  • New toasts are announced politely by default. Set priority: 'high' on important ones (errors, warnings) to interrupt and announce immediately.
  • The close button carries an accessible label (closeLabel, default "Dismiss"); it's hidden from the a11y tree until the stack is hovered or focused, then revealed.
  • Keep toast text short and self-contained — they disappear, so don't put the only copy of critical information in one.
  • All enter/exit, stacking, and swipe animations honour prefers-reduced-motion, and the countdown progress bar is hidden under reduced motion.

© 2026 Appica UI. A free component library, crafted by the Appica team.