Components / Print
Print Toast
Screen-printed toasts on top of sonner, with a spot ink badge and an optional action.
Installation
npx shadcn@latest add https://jiaweing.com/r/print-toast.jsonWith the @jiaweing namespace set up, use @jiaweing/print-toast in place of the URL.
Usage
tsx
import { PrintToaster, printToast } from "@/components/ui/print-toast";tsx
// Once, in your root layout
<PrintToaster />
// Anywhere
printToast({
title: "Saved",
description: "Your changes are live.",
tone: "lime",
badge: "OK",
});- printToast works with any sonner Toaster on the page, so keep yours if you already have one.
Props
printToast(options)
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | - | The bold first line. |
| description | ReactNode | - | A smaller second line. |
| tone | "paper" | "pink" | "lime" | "cyan" | "amber" | "foil" | "lime" | The spot ink of the badge. |
| badge | ReactNode | "!" | A short word, icon or emoji on the badge. |
| action | { label: string; onClick: () => void } | - | A button on the right. The toast closes after it. |
| duration | number | 4000 | How long it stays, in milliseconds. |
| id | string | number | - | Pass the same id to replace a toast in place. |
PrintToaster
| Prop | Type | Default | Description |
|---|---|---|---|
| ...props | ToasterProps | - | Every sonner Toaster prop. position defaults to bottom-right. |
MIT licensed. Copy it, change it, ship it.