ask-sonner

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

Updated Jul 3, 2026
One-click install
npx skills add https://github.com/alex-jordan547/agent-setup --skill ask-sonner-alex-jordan547
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ask-sonner
Source: https://github.com/alex-jordan547/agent-setup/tree/main/archive/2026-09-10/ask-sonner
Command: npx skills add https://github.com/alex-jordan547/agent-setup --skill ask-sonner-alex-jordan547

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sonner.

What problem does it solve? Sonner toasts often fail in confusing ways: they never appear, render twice, ignore Tailwind classes, hide behind modals, or ignore dark mode. This Skill provides the correct setup pattern, the right toast() call for each scenario, and a symptom-to-fix troubleshooting table so you resolve issues without digging through docs. ## Core Features & Use Cases - Setup and call selection: Mount one <Toaster /> at the root and pick the right call — toast.success, toast.loading, toast.promise, or toast.custom — for each notification scenario. - Styling escalation ladder: Progress from richColors and inline styles through classNames with !important to fully headless toast.custom() for design-system toasts. - Troubleshooting table: Maps symptoms like duplicate toasts, lost styles in Astro or Shadow DOM, stacking-context clipping, and stuck toast.promise loaders to concrete fixes. - Use Case: Your toasts render unstyled after adding view transitions in Astro — the Skill tells you to explicitly import sonner/dist/styles.css in a layout. ## Quick Start Ask how to fix Sonner toasts that appear twice in your Next.js app and follow the guidance to keep a single Toaster mounted in the root layout.

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 — and call `toast()` from client code like event handlers. Never render a Toaster per page, 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 to a promise.

Why do my Sonner toasts appear twice?

Duplicate toasts come from two mounted Toasters (layout and page) or from calling `toast()` inside an effect under React StrictMode's dev double-invoke. Keep one Toaster and fire toasts from event handlers, or pass a stable id so the second call updates instead.

Why do Tailwind classes not work on Sonner toasts?

Sonner's injected default styles win the cascade over utility classes. Mark classes `!important` (e.g. `!text-red-900`), or switch to `unstyled` or headless `toast.custom()` for full control over the markup.

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.

Why is my Sonner toast stuck on loading forever?

A `toast.promise` loading toast waits until its promise settles, so a promise that never resolves or rejects leaves it spinning. It can also be caused by `duration: Infinity` or `dismissible: false` on regular toasts.