Components
Toast
Non-blocking stacked and anchored notifications with spring physics, swipe-to-dismiss, and promise state transitions.
"use client";
import { Button } from "@/components/ui/button";
import { toastManager } from "@/components/ui/toast";
export default function Particle() {
return (
<Button
onClick={() =>
toastManager.add({
description: "Friday, November 20 at 4:00 PM",
title: "Event scheduled",
})
}
variant="outline"
>
Show Toast
</Button>
);
}
Installation
pnpm dlx shadcn@latest add @taut-ui/toast
Usage
Mount ToastProvider (and optionally AnchoredToastProvider) once in your root layout:
import { AnchoredToastProvider, ToastProvider } from "@/components/ui/toast"
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<ToastProvider position="bottom-right">
<AnchoredToastProvider>{children}</AnchoredToastProvider>
</ToastProvider>
)
}Trigger notifications anywhere using toastManager:
import { toastManager } from "@/components/ui/toast"
toastManager.add({
title: "Changes saved",
description: "Your workspace preferences have been updated.",
type: "success",
})Examples
Success
"use client";
import { Button } from "@/components/ui/button";
import { toastManager } from "@/components/ui/toast";
export default function Particle() {
return (
<Button
onClick={() =>
toastManager.add({
description: "Your deployment is now live on gru1.",
title: "Deployment succeeded",
type: "success",
})
}
variant="outline"
>
Success Toast
</Button>
);
}
Error
"use client";
import { Button } from "@/components/ui/button";
import { toastManager } from "@/components/ui/toast";
export default function Particle() {
return (
<Button
onClick={() =>
toastManager.add({
description: "Could not verify webhook signature.",
title: "Delivery failed",
type: "error",
})
}
variant="outline"
>
Error Toast
</Button>
);
}
With Action
"use client";
import { Button } from "@/components/ui/button";
import { toastManager } from "@/components/ui/toast";
export default function Particle() {
return (
<Button
onClick={() => {
const id = toastManager.add({
actionProps: {
children: "Undo",
onClick: () => toastManager.close(id),
},
description: "Moved to trash. You can restore it within 30 days.",
title: "Project archived",
});
}}
variant="outline"
>
Toast with Action
</Button>
);
}
Promise & Loading
"use client";
import { Button } from "@/components/ui/button";
import { toastManager } from "@/components/ui/toast";
export default function Particle() {
return (
<Button
onClick={() => {
toastManager.promise(
new Promise<string>((resolve) =>
setTimeout(() => resolve("v2.4.0"), 1800),
),
{
error: "Build failed",
loading: {
description: "Compiling assets and running checks...",
title: "Publishing release",
},
success: (version) => ({
description: `Release ${version} is now available.`,
title: "Release published",
}),
},
);
}}
variant="outline"
>
Run Promise Toast
</Button>
);
}
Anchored
"use client";
import { CopyIcon } from "lucide-react";
import { useRef } from "react";
import { Button } from "@/components/ui/button";
import { anchoredToastManager } from "@/components/ui/toast";
export default function Particle() {
const buttonRef = useRef<HTMLButtonElement | null>(null);
return (
<Button
onClick={() =>
anchoredToastManager.add({
data: { tooltipStyle: true },
positionerProps: { anchor: buttonRef.current, sideOffset: 8 },
timeout: 1800,
title: "Copied to clipboard",
})
}
ref={buttonRef}
variant="outline"
>
<CopyIcon />
Copy Token
</Button>
);
}
API Reference
ToastProvider
Wraps Base UI Toast.Provider and renders the floating toast stack viewport.
| Prop | Type | Default | Description |
|---|---|---|---|
position | "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right" | "bottom-right" | Viewport corner or edge where toasts stack |
timeout | number | 5000 | Auto-dismiss duration in milliseconds |
limit | number | 3 | Maximum number of visible stacked toasts |
portalProps | Toast.Portal.Props | - | Props forwarded to the internal Toast.Portal |
AnchoredToastProvider
Renders toasts anchored to specific DOM elements via anchoredToastManager.
toastManager / anchoredToastManager
Imperative manager instances created with Toast.createToastManager().
| Method | Description |
|---|---|
add(options) | Creates a toast and returns its id |
update(id, options) | Updates an existing toast by id |
close(id) | Dismisses a toast by id |
promise(promise, state) | Transitions a toast through loading, success, and error |