Prodular UI

Toast

A brief notification in a stack at the corner of the screen, with status icons, an optional action and progress for async work.

npx prodular-ui add toast

Status types

Pass type success, info, warning or error. Hover the stack to expand it.

Action and progress

actionProps adds a button. promise() shows a spinner, then the result.

Anatomy

// Once, in the root layout<Toaster />
// Anywheretoast.add({  type: "success",  title: "Invoice sent",  description: "Northgate Logistics will get it at ap@northgate.co.",  actionProps: { children: "Undo", onClick: undoSend },})

Guidance

Use it when

  • Use to confirm that something happened in the background: saved, sent, exported, archived.
  • Offer Undo with actionProps instead of asking for confirmation first.
  • Use promise() for work that takes more than a second.

Avoid

  • Errors that block the user. Show them inline next to the field or as an Alert.
  • More than one toast for the same event.
  • Long text. One title of a few words, one sentence of description.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Mount <Toaster /> once near the root of the app. Then call toast.add({ title, description, type }) from anywhere.
  • Use type success, info, warning, error or loading. destructive is accepted as an alias of error.
  • Write the title as the outcome in past tense: Invoice sent, 3 issues archived.
  • Add actions with actionProps: { children: "Undo", onClick }. Do not render buttons inside description.
  • For a separate stack, create one with createToastManager() and pass it to Toaster as toastManager.

API

toast.add

PropTypeDefaultDescription
type"success" | "info" | "warning" | "error" | "destructive" | "loading"Picks the status icon.
title / descriptionReactNodeOne short title and an optional sentence.
actionPropsButtonPropsRenders an outline action button below the description.
timeoutnumber5000Milliseconds before it closes. 0 keeps it open.

Toaster

PropTypeDefaultDescription
toastManagerToastManagertoastThe manager this stack listens to.
limitnumber3Visible toasts before older ones are hidden.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add toast# or, with the registry in components.jsonnpx shadcn@latest add @prodular/toast