Toast

A short result message, bottom centre.

$ npx shadcn@latest add https://mahrdesign.faizintifada.com/r/toast.json

Statuses

4 statuses: success (default), info, warning, danger. Pill 60 high, status disc 32 with a white 20 icon, message 16/24 strong, close ×. No neutral, no title + body. At most one secondary action button ("Lihat data" when the result is not on screen); a toast with an action stays 8 s.

Kontak darurat disimpan
Putri Ramadhani sudah ditambahkan. Undangan login terkirim.
Slip Desember terbit Kamis, 24 Des
Disimpan, tapi 2 karyawan belum lengkap

Show a toast

Bottom centre, 5 s (8 s with an action). Offset 24 (96 on screens with a pager). Sonner's stack: up to 3; the newest in front, the older ones peek above it (lifted 14, scaled −5 % each, content faded). Point at the stack (or Tab into it) to spread it upward with a 14 gap; every timer pauses until you leave. Motion is Sonner's: rises from below + fade, 400 ms; swipe down closes.

When to use

  • A Sheet or Dialog closed after saving: "Kontak darurat disimpan".
  • A request went to someone else: "Permintaan cuti dikirim ke HR".
  • A background job finished: "Slip dikirim ke 43 karyawan".

When not to use

  • An error the user must fix → inline field error, or an error line in the Sheet/Dialog.
  • A lasting status (Menunggu HR) → Badge or Callout on the page.
  • A copy action → the copy button turns into a tick; no toast.
  • The change is already visible on screen → nothing.

Do and don't

DoSay what happened, and to what"Permintaan cuti dikirim ke HR" after Kirim ke HR closes the sheet; the list behind updates at the same time.
Don't"Berhasil!", validation errors"Berhasil!" says nothing. "Tanggal wajib diisi" belongs under the field, not in a toast that disappears after 5 s.

Installation

Add Toast with the shadcn CLI (your project needs a components.json and the MaHR theme: https://mahrdesign.faizintifada.com/r/theme.json), or copy the files by hand.

terminal
bunx --bun shadcn@latest add https://mahrdesign.faizintifada.com/r/toast.json

API

import { toast, Toaster, ToastPill } from "@/components/ui/sonner"
PropTypeDefaultDescription
toast.success(message, options?)(message: string, { action?: { label, onClick } }) => id–Also toast.info / toast.warning / toast.danger. Past tense, max 48 characters. One action at most; it closes the toast. With an action: 8 s, else 5 s.
toast.dismiss(id?)(id?) => void–Close one or all.
<Toaster offset>number24Mounted once in AppShell. 96 on screens with a pager.
ToastPill status · message · action · onClose"success" | "info" | "warning" | "danger" · ReactNode · { label, onClick }? · () => void–The pill itself, for previews.