Components
Toast
Transient feedback with optional actions, pausing and keyboard dismissal.
Ombelle · light
Toast
Installation
Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.
pnpm dlx @ombelle-ui/cli@1.1.2 add toastAdds components/ui/toast.tsx and installs react, @radix-ui/react-toast, clsx, tailwind-merge with lifecycle scripts disabled. This is a client component.
In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.
Usage
example.tsx
import { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose } from '@/components/ui/toast'
export function Example(){return <ToastProvider><Toast defaultOpen><ToastTitle>Changes saved</ToastTitle><ToastDescription>Your project is up to date.</ToastDescription><ToastClose /></Toast><ToastViewport /></ToastProvider>}The Base UI edition uses useToastManager and a native toast object; see the exported example for that edition.
API and states
- API
- ToastProvider (duration), ToastViewport (stack), Toast (variant, duration), ToastTitle, ToastDescription, ToastAction (altText), ToastClose, ToastPromise (promise, loading, success, error), toastDuration
- Minimum states
- Open, timed dismissal by content length, kept open with an action, paused on hover and focus, pending promise, stacked, swipe, focus
- Native basis
- Reviewed Toast primitive; Base UI uses its native toast manager
- Styles
- Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.