Skip to content

Toast

Download .md

A toast confirms that something happened, such as a save or a send, with a short message that goes away by itself.

  • Use it to confirm an action the person just took: “Rilis tersimpan.”
  • Use it for errors that are not tied to one field: “Belum bisa mengirim. Coba lagi sebentar.”
  • Show validation errors under their field, not in a toast; the message comes from the backend.
  • Use a Dialog when the person must decide something.
React
Vue
DoConfirm what just happened in a few words.
Don'tDon't put errors, long text or decisions in a toast; it closes on its own.
123
  1. 1Status icon
  2. 2Message
  3. 3Close

A message on popover with a border, radius-lg and shadow-lg, with an icon in the status color: success, info, warning or destructive. Toasts stack in a corner and follow the page’s mode.

toast() for a plain message, and toast.success, toast.info, toast.warning, toast.error for a status icon.

React Vue Flutter Type Default Use
toast.success(message) from sonner toast.success(message) from vue-sonner ShadToaster.of(context).show(ShadToast(...)) function none Shows a toast.
<Toaster /> once in the app <Toaster /> once in the app ShadToaster (in ShadApp) element none Where toasts appear.
position on Toaster position on Toaster alignment string bottom-right Corner of the screen.

The Sosialoka Toaster reads light or dark from data-theme or the .dark class on <html>, so it needs no theme provider.

import { toast } from "sonner"
import { Button } from "@/components/ui/button"
import { Toaster } from "@/components/ui/sonner"
export default function SonnerDemo() {
return (
<div className="flex flex-wrap gap-2">
<Button variant="outline" onClick={() => toast.success("Rilis tersimpan.")}>
Simpan
</Button>
<Button variant="outline" onClick={() => toast.error("Belum bisa mengirim. Coba lagi sebentar.")}>
Kirim
</Button>
<Toaster />
</div>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/sonner.json
  • Toasts are announced politely by screen readers and don’t take focus.
  • Keep them short; anything people must act on belongs in the page or a dialog.