Skip to content
synccn

Toast

Stacked notifications with actions, promises and hover to expand.

Installation

$ pnpm dlx shadcn@latest add @synccn/toast

First time in this project? Connect synccn with one command.

Usage

import { Toaster, toast } from "@/components/ui/toast";// once, near the root<Toaster />// anywheretoast.success("Changes saved")

API reference

Generated from the component's TypeScript types, so it always matches the code.

Toaster

Renders the toast stack. Mount once near the root of your app.

Takes no props.

toast

Shows a toast. Call it anywhere once <Toaster /> is mounted. toast("Saved"), toast.success(...), toast.error(...), toast.promise(...)

Takes no props.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

  • lib/utilscn (merges class names)
  • lib/hooksuseIsClient (renders portals only in the browser)

npm packages

Accessibility

  • Toasts are announced through a polite live region. Hovering a toast pauses its timer.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: status
  • ARIA attributes: aria-label, aria-live
  • Announces changes to screen readers