snapshot of https://github.com/shadcn-ui/ui.git (main, 2026-09-15; blobs > 131072B omitted)
This commit is contained in:
25
apps/v4/examples/base/toast-promise.tsx
Normal file
25
apps/v4/examples/base/toast-promise.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
"use client"
|
||||
|
||||
import { Button } from "@/styles/base-nova/ui/button"
|
||||
import { toast } from "@/styles/base-nova/ui/toast"
|
||||
|
||||
export function ToastPromise() {
|
||||
function showToast() {
|
||||
toast.promise(
|
||||
new Promise<{ name: string }>((resolve) => {
|
||||
window.setTimeout(() => resolve({ name: "Event" }), 2000)
|
||||
}),
|
||||
{
|
||||
loading: "Creating event…",
|
||||
success: (data) => `${data.name} created.`,
|
||||
error: "Could not create event.",
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Button variant="outline" onClick={showToast}>
|
||||
Create Event
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user