Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Toast

A short message that stacks at the edge of the screen and leaves on its own, by swipe or from its close button.

Built on the headless Toast.See its API in Docs

Rendered by React 19.3.1

toast.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/toast.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Render Toaster once near the root of the app, then call toast.add({ title, description }) from anywhere. type (success, info, warning, error, loading) picks the icon, and actionProps adds an action button. Stacking, timeouts, swipe to dismiss and the live region come from the headless Toast.

import {
  Toaster,
  Toast,
  ToastAction,
  ToastClose,
  ToastContent,
  ToastDescription,
  ToastPortal,
  ToastProvider,
  ToastTitle,
  ToastViewport,
} from '@/components/ui/toast'

Examples

Default

A button that adds a toast.

Its preview and code are at the top of the page.

Differences from shadcn's: this item stands in for shadcn's sonner (the sonner library), and its props follow Base UI's Toast. toast("Saved") is toast.add({ title: "Saved" }); toast.success(…) and the other type helpers are toast.add({ type: "success", … }); toast.promise is the manager's promise, and toast.dismiss(id) is toast.close(id). Toaster takes the Toast provider's props (limit, timeout, toastManager) in place of sonner's position, richColors, theme and expand. There is no next-themes dependency.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Toast's API reference.