Sonner

A toast component for displaying brief, non-intrusive notifications.

Installation

Import the component from the passport-ui package.

components/example.tsx
1
2
3
import { Toaster } from "passport-ui";
import { toast } from "sonner";
import { Button } from "passport-ui";

Usage

Basic example showing how to use the component.

components/example.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{/* Add Toaster to your app root */}
<Toaster position="bottom-right" />
{/* Trigger toasts */}
<div className="flex gap-2 flex-wrap">
<Button onClick={() => toast("Default notification")}>
Default
</Button>
<Button
variant="outline"
onClick={() =>
toast("Meeting reminder", {
description: "You have a meeting in 10 minutes.",
action: {
label: "View",
onClick: () => console.log("View clicked"),
},
})
}
>
With Action
</Button>
<Button onClick={() => toast.success("Success message")}>
Success
</Button>
<Button onClick={() => toast.error("Error message")}>
Error
</Button>
<Button onClick={() => toast.warning("Warning message")}>
Warning
</Button>
<Button onClick={() => toast.info("Info message")}>
Info
</Button>
</div>

Additional resources

Documentation and examples are available in Storybook.