ask-sonner

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

Updated Sep 5, 2023
One-click install
npx skills add https://github.com/eyenalxai/dotfiles --skill ask-sonner-eyenalxai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ask-sonner
Source: https://github.com/eyenalxai/dotfiles/tree/main/.agents/skills/ask-sonner
Command: npx skills add https://github.com/eyenalxai/dotfiles --skill ask-sonner-eyenalxai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sonner, and includes references (resource) components.

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 authoritative guidance for wiring up the Toaster correctly, choosing the right toast() call, and diagnosing every common failure mode. ## Core Features & Use Cases - Setup and call selection: Mount one <Toaster /> at the root and pick the right API — typed toasts, toast.promise, toast.loading, action buttons, or headless toast.custom. - Styling escalation ladder: Progress from richColors and inline styles through classNames with !important to fully headless custom JSX, plus theming with next-themes. - 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 toast renders behind a modal in a Next.js app — the Skill identifies the stacking-context cause and tells you to move <Toaster /> to the document root outside any portal container. ## Quick Start Ask how to fix a Sonner toast that appears 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 toast notifications in Next.js?

Mount a single `<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?

Use `toast.promise(promise, { loading, success, error })` when the flow is tied to a promise, or manage it manually: capture `const id = toast.loading('Uploading…')` and later call `toast.success('Uploaded', { id })` to update the same toast in place.

Why does my Sonner toast appear twice in React?

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 at the root 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`) via the `classNames` option, or switch to `unstyled: true` 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"` or wire your theme provider by passing the resolved theme from next-themes, e.g. `<Toaster theme={resolvedTheme} />`.

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

An ancestor element creates a stacking context via 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.