Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Sonner examples · Content

Toast with Custom Icon Sonner for React

A toast with its own check icon in place of the type icon, and a description.

Framework
UI library

The icon option puts any element in a toast's icon slot. This toast passes a Lucide CheckCircleIcon with a description, on a plain toast call. Use it when an icon should say more than the type icons do.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

What does this toast pass?

toast is called with "Payment successful". The second argument sets description to "Your payment has been processed" and icon to a CheckCircleIcon with className="size-4".

Why does this call use plain toast?

The call is plain toast, so the icon on screen is the icon you passed. toast.success would use Toaster's CircleCheckIcon unless that call also passes icon.

Where do the icon and description sit?

description renders under the title. The icon element renders in the icon slot beside that text. This file passes both, and nothing else.

What size is the icon?

size-4, from the className on CheckCircleIcon. That matches the icons Toaster sets for success, error, warning, info, and loading, which are also size-4.

Is this icon hidden from assistive tech?

Yes. The CheckCircleIcon sets aria-hidden="true", like the icons on Toaster. The title, Payment successful, carries the meaning.

Do I still need Toaster?

Yes. The demo renders its own Toaster beside the button; in an app, render one near the root. The custom icon is passed on the call, and Toaster is what shows the toast.