Toast
Notifications that unfold out of a capsule at the top edge. Swipe one up to dismiss it.
Installation#
pnpmnpmyarnbun
$ pnpm dlx shadcn@latest add @liquikit/toastNeeds the @liquikit registry in your components.json. Set it up once.
Usage#
import { ToastProvider, ToastViewport, useToast } from "@/components/liquikit/toast"// Once, near the root of your app
<ToastProvider>
<App />
<ToastViewport />
</ToastProvider>
// Anywhere inside it, in a client component
const toast = useToast()
toast.add({ title: "Copied", description: "The link is on your clipboard." })The provider and the viewport are imported by name, so they can go in a layout that renders on the server. The viewport takes a container, so toasts can live inside a card instead of at the top of the window.
API Reference#
Toast.Viewport
| Prop | Type | Default |
|---|---|---|
theme | "light" | "dark"Light or dark toasts. | — |
refraction | "interactive" | "always"When the glass bends the page. | "interactive" |
container | BaseToast.Portal.Props["container"]Where the popup renders. Defaults to the end of the body. | — |