Skip to content
Ballpoint

Toast

Notes pinned to the corner of the page that stack, fan out and swipe away; toast() from anywhere.

From shadcn/ui
Built on Base UI Toast

Installation

pnpm dlx shadcn@latest add @ballpoint/toast

Usage

tsx
// app/layout.tsx: once, near the root
import { Toaster } from "@/components/ui/toast"

<body>
  {children}
  <Toaster />
</body>

// anywhere
import { toast } from "@/components/ui/toast"

toast("Page torn out", { action: { label: "Undo", onClick: restore } })
toast.success("Saved")
toast.error("Couldn't send")
toast.promise(save(), { loading: "Saving…", success: "Saved", error: "Couldn't save" })

Examples

More kinds

Info, warning, a note that stays until closed, and clearing them all.

Promise

One note that follows a save: pending, then done or failed.

Undo

Removing something posts a note whose action puts it back.

  • Dear Ada
  • Shopping list
  • Sketch of a lake
  • Recipe

API reference

toast(title, options)
string id

Also toast.success, .error, .warning, .info, .loading (stays until dismissed), .promise, .update and .dismiss(id?).

options
{ description, action, timeout, priority, id, onClose }

action is { label, onClick }; timeout 0 keeps it up; priority "high" announces it at once.

Toaster limit
default 3
number

How many notes show at once; older ones wait.

Toaster timeout
default 5000
number

ms before a note takes itself down.

Every other prop goes to Base UI's Toast.

Pen settings

The drawing also takes draw, roughness, passes, radius, corners, shadow, weight and speed, as props or from the nearest InkProvider. What each one does.