ask-sonner

Guides setup, styling, and troubleshooting of Sonner toast notifications in React applications.

Updated Aug 28, 2026
One-click install
npx skills add https://github.com/trobias/portfolio-nextjs-v2 --skill ask-sonner-trobias
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ask-sonner
Source: https://github.com/trobias/portfolio-nextjs-v2/tree/main/.agents/skills/ask-sonner
Command: npx skills add https://github.com/trobias/portfolio-nextjs-v2 --skill ask-sonner-trobias

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sonner.

What problem does it solve? Integrating the Sonner toast library into React and Next.js apps often leads to subtle bugs: toasts that never appear, duplicate notifications, styles that ignore Tailwind classes, or toasts hidden behind modals. This Skill provides the exact setup pattern, API reference, and a symptom-to-fix troubleshooting table so you resolve these issues immediately. ## Core Features & Use Cases - Correct Setup Guidance: Enforces the two-piece pattern — one <Toaster /> mounted at the root and toast() called from client code — preventing duplicate or missing toasts. - Call Selection & Recipes: Maps each need (success, loading, promise, action buttons, custom JSX) to the right toast() variant, including updating toasts by id and persisting with duration: Infinity. - Styling Escalation Ladder: Walks from defaults and richColors through classNames with !important up to fully headless toast.custom() for design-system integration. - Use Case: Your toast renders behind a modal in a Next.js app. The troubleshooting table identifies the stacking-context cause and tells you to move <Toaster /> to the document root outside any portal container. ## Quick Start Ask how to set up Sonner in a Next.js layout and show a success toast after a form submission.

Frequently Asked Questions about ask-sonner

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Sonner toasts in a Next.js app?▼

Mount one `<Toaster />` in your root layout.tsx — it works inside server components — then call `toast()` from any client-side event handler or effect. Never render the Toaster per-page or conditionally, since a second mounted Toaster duplicates every toast.

How do I show a loading toast that becomes a success toast in Sonner?▼

Call `toast.loading('Uploading…')` and keep the returned id, then call `toast.success('Uploaded', { id })` to update it. Alternatively, use `toast.promise(promise, { loading, success, error })` to tie the transition directly to a promise.

Why do my Tailwind classes have no effect on Sonner toasts?▼

Sonner's injected default styles win the cascade over utility classes. Mark classes with `!important` (e.g. `!text-red-900`) via the `classNames` option, or go headless with `toast.custom()` for full styling control.

Why does the same Sonner toast appear twice?▼

Duplicate toasts usually mean two Toasters are mounted, such as one in the layout and one in a page — keep only one. It can also come from firing `toast()` in an effect under React StrictMode's dev double-invoke; fire from the event handler or pass a stable id.

Does Sonner follow the system dark mode automatically?▼

No. The `theme` prop defaults to `'light'` and does not track the OS. Set `theme="system"` on the Toaster, or pass the resolved theme from a provider like next-themes via `<Toaster theme={resolvedTheme} />`.

Why is my Sonner toast hidden behind a modal or dialog?▼

An ancestor element creates a stacking context through transform, filter, or overflow, or the overlay out-z-indexes the toaster. Move `<Toaster />` to the document root, outside any dialog or portal container, so it stacks above the modal.