Toast
Brief messages that stack neatly, expand on hover, swipe away, and turn a loading state into success or error in place.
Used in Pro blocks: Artifact, Chat Sidebar, Chat Thread, and 7 more
pnpm dlx shadcn@latest add https://hextaui.com/r/toast.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add @base-ui/react @tabler/icons-react cnCopy and paste the following code into your project.
components/ui/toast.tsx components/ui/button.tsx components/ui/spinner.tsx Update the import paths to match your project setup.
Add <Toaster /> once, near the root of your app.
Then call toast from anywhere, including outside React components.
Toasts stack into a neat pile with the newest in front. Hover or focus the pile to fan it out; every timer pauses while you read. Swipe a toast toward its edge to dismiss it.
Every toast uses the same calm surface; only the icon carries the color.
toast.promise shows a spinner, then turns into a success or error toast in place, with the icon popping in as it changes.
Pass action for a button such as Undo. Clicking it also dismisses the toast.
Keep the id from toast.loading and change it with toast.update, including its type.
Give a toast an id and calling it again updates the existing one instead of stacking a copy.
| Key | Action |
|---|---|
| F6 | Moves focus into the toasts and fans them out. |
| Tab | Moves between toast actions and close buttons. |
| Esc | Dismisses the focused toast. |
- Toasts are announced politely;
toast.erroris announced right away. - Timers pause while the pointer or focus is on the toasts, so nobody has to race a countdown.
- Close buttons appear on hover and focus, and are always visible on touch screens.
- With reduced motion, toasts fade instead of sliding.
| Prop | Type | Default |
|---|---|---|
positionPhones always use the full width. | "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "bottom-right" |
limitToasts shown at once; older ones fade out. | number | 3 |
timeoutDefault time on screen, in ms. | number | 5000 |
| Attribute | Description |
|---|---|
data-slot="toaster" | The viewport, with data-position. |
data-slot="toast" | Each toast, with data-type, data-expanded and data-swiping. |
| Prop | Type | Default |
|---|---|---|
description | ReactNode | – |
action | { label: ReactNode; onClick?: (event) => void } | – |
idReuse to update instead of duplicating. | string | – |
timeoutDefaults to the Toaster timeout. Long messages stay up longer, about 250 words a minute. | number | – |
priority | "low" | "high" | "low" |
onClose | () => void | – |
onRemove | () => void | – |
Also toast.success, toast.error, toast.warning, toast.info, toast.loading, toast.promise, toast.update and toast.dismiss. Each returns or takes the toast's id.
- ButtonButtons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- SpinnerA loading indicator with Apple-style ticks or a breathing ring that can wait before showing and stay long enough not to flicker.
- AlertInline messages for status and feedback, with a neutral surface, a colored icon and a dismiss that collapses smoothly.
- EmptyA placeholder for screens with nothing to show yet, with an icon, a message and the next action.
- ProgressA bar or ring that shows how far a task has come, eases between updates and slides while the total is unknown.
- SkeletonPlaceholders that wait 150ms before showing, take the exact size of the content they wrap, and fade it in without moving anything.
Used in Pro blocks
Blocks that build on Toast.
- ArtifactThe panel beside an AI chat that shows what the model made. Handles content still streaming, a sandboxed preview and versions you can restore.
- Chat SidebarThe sidebar of a chat app, with pinned chats, projects and recents. Handles rename in place, delete with undo and chats still replying.
- Chat ThreadThe conversation view of an AI chat. Handles replies that stream, edit and retry, and versions of a reply you can switch between.
- HextaAIA complete AI chat app built from the HextaUI AI blocks. Handles streaming, tool approvals and plan review end to end on AI SDK message parts.
- Stack TraceA crash shown the way a developer reads it. Your code comes first, framework frames fold away and every cause is listed in order.
- API keysThe API keys page of an AI product. Handles a secret shown only once, revoke with undo and rotation with a grace period.
Every block comes with HextaUI Pro, and Prompt Input is free.