ask-sonner

Guides setup, usage, styling, and troubleshooting of the Sonner React toast library.

Updated Jul 15, 2026
One-click install
npx skills add https://github.com/Alex918-stack/papertrader --skill ask-sonner-alex918-stack
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ask-sonner
Source: https://github.com/Alex918-stack/papertrader/tree/main/agent/skills/ask-sonner
Command: npx skills add https://github.com/Alex918-stack/papertrader --skill ask-sonner-alex918-stack

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sonner.

What problem does it solve? Developers integrating Sonner toasts in React and Next.js apps often hit issues like toasts not appearing, duplicating, losing Tailwind styles, sitting behind modals, or ignoring dark mode, and this Skill provides direct answers and fixes. ## Core Features & Use Cases - Setup and Call Selection: Mount one <Toaster /> at the root and pick the right toast() variant, including success, error, loading, promise, and headless custom toasts. - Styling and Theming: Apply an escalation ladder from richColors and inline styles to classNames with !important and fully headless toast.custom(), plus icon swaps and dark mode via theme="system" or next-themes. - Troubleshooting Table: Diagnose duplicate toasts from double-mounted Toasters, missing styles in Astro or Shadow DOM, stacking context issues, and stuck toast.promise loading states. - Use Case: When a toast renders behind a modal in a Next.js app, the Skill directs 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 a single `<Toaster />` in your root layout.tsx, which 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?

Use `toast.promise(promise, { loading, success, error })` to tie the toast lifecycle to a promise, or manage it manually by calling `toast.loading('Uploading…')` and then `toast.success('Uploaded', { id })` with the same id to update it.

Why do my Sonner toasts appear twice in React?

Duplicate toasts usually come from two mounted Toasters, such as one in the layout and one in a page, so keep only one. They can also come from `toast()` firing in an effect under StrictMode double-invoke; fire from event handlers or pass a stable id instead.

Why do Tailwind classes not work on Sonner toasts?

Sonner's injected default styles win the cascade over your classes. Mark classes with `!important` (for example `!text-red-900`), or use `unstyled` or headless `toast.custom()` for full control over the markup.

Does Sonner support 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 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, to fix the layering.