Skip to content
Ask Sonner

Ask Sonner Skill

The Sonner author's own guide skill for the React toast library: setting up the Toaster, choosing the right toast() call, styling from defaults to headless, and fixing toasts that misbehave.

GitHub Docs

Install

Install with the skills CLI

One command for Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf and dozens of other agents. Needs Node.js; the skill is fetched straight from emilkowalski/skills.

$ npx skills add emilkowalski/skills --skill ask-sonner

Run it in a terminal. The CLI finds the agents installed on your machine, asks which ones to add the skill to, and whether to install it into the folder you ran it from or for all your projects.

Other ways to install

Copy the whole skill folder — SKILL.md and any scripts or references beside it — into ~/.claude/skills/ask-sonner/, where Claude Code picks it up in every project. Only git is needed.

tmp=$(mktemp -d) && \
  git clone --depth 1 --branch main https://github.com/emilkowalski/skills.git "$tmp" && \
  mkdir -p ~/.claude/skills && \
  cp -R "$tmp"/skills/ask-sonner ~/.claude/skills/ask-sonner

No scripts or references next to it? Saving the SKILL.md alone as ~/.claude/skills/ask-sonner/SKILL.md works too.

Using another agent? Its personal skills folder
Codex
~/.agents/skills/
Cursor
~/.cursor/skills/
GitHub Copilot
~/.copilot/skills/
Gemini CLI
~/.gemini/skills/
Windsurf
~/.codeium/windsurf/skills/
OpenCode
~/.config/opencode/skills/

About

  • Written by Sonner's author, with full prop tables in API.md
  • Two-rule setup: one Toaster at the root, toast() from client code
  • Table of toast() variants: success, loading, promise, actions, custom and headless
  • Recipes for updating, persisting, dismissing and multiple toasters
  • Styling escalation ladder from defaults to headless
  • Troubleshooting table for duplicate, missing, unstyled and hidden toasts

Ask Sonner is a skill by Emil Kowalski, the author of Sonner, the widely used React toast library (it is also the toast component behind shadcn/ui). It gives a coding agent the library's correct usage straight from its maker, so the agent answers from the skill rather than from outdated memory. A companion API.md file holds the full prop tables for <Toaster /> and toast().

Setup is reduced to two rules: mount exactly one Toaster near the root (in Next.js, in the layout) and call toast() only from client code, returning a server action's result to the client first. A table maps each need to the right call: plain, success/error/info/warning, loading, promise-driven, toasts with action and cancel buttons, custom JSX and fully headless toast.custom(). Recipes cover updating a toast by id, persisting and dismissing, links inside toasts, multiple targeted toasters and the difference between onDismiss and onAutoClose.

Styling follows an escalation ladder (defaults with richColors, inline styles, classNames with !important, then headless) plus icon and theme settings; theme defaults to light and does not follow the OS unless set to system. A troubleshooting table covers the common failures: toasts that never appear or appear twice, Tailwind classes with no effect, styles lost in Astro or the Shadow DOM, toasts behind a modal, ignored dark mode, stuck promise toasts, swipe direction and mobile offsets. MIT-licensed.

Try it

Once installed, ask your agent something like:

Our Sonner toasts show up twice and ignore dark mode in Next.js. Fix it.

SKILL.md

The instructions your agent loads, as published by Emil Kowalski.

SKILL.md
name
ask-sonner
description
Guide to Sonner, the React toast library — install and wire up the Toaster, pick the right toast() call, promise and loading toasts, updating, dismissing and persisting toasts, styling, theming and icons, positioning and multiple toasters. Use when working with Sonner or troubleshooting it — toasts that don't appear, appear twice, lose their styles, ignore Tailwind classes, sit behind a modal, or don't follow dark mode.

Working With Sonner

Initial Response

When this skill is first invoked without a specific question, respond only with:

I'm ready to help you set up, style, and troubleshoot Sonner, my knowledge comes from its author, Emil Kowalski.

Do not provide any other information until the user asks a question.

A guide skill for Sonner, the toast library. When a task involves Sonner — wiring it up, rendering toasts, styling them, or fixing them — answer from this file first. Full prop tables for <Toaster /> and toast() live in [API.md](API.md); read it when you need an exact prop name, type, or default.

Setup

Two pieces, and only two:

  1. One `<Toaster />`, mounted once, as close to the root as possible (in Next.js: layout.tsx — it works inside server components). Never render it per-page or conditionally; a second Toaster without its own id duplicates every toast.
  2. `toast()` called from client code — event handlers, effects, callbacks. It's a plain function, no hook or provider needed, but it does nothing on the server: in a server action, return the result and call toast() in the client code that receives it.
import { Toaster } from 'sonner'; // once, in layout
import { toast } from 'sonner';   // anywhere client-side
Picking the right call
You wantCall
Plain messagetoast('Title') — add { description } for a second line
Success / error / info / warning icontoast.success('…'), toast.error('…'), etc.
Spinner while you manage state yourselftoast.loading('…'), then update it by id
Loading → success/error tied to a promisetoast.promise(promise, { loading, success, error }) — success/error accept functions receiving the resolved value/error
Button that does something{ action: { label, onClick } } — closes the toast unless onClick calls event.preventDefault(); cancel is the secondary variant
Custom JSX, default toast shelltoast(<jsx />)
Custom JSX, no styles at alltoast.custom((t) => <jsx />) — headless, t gives you the id to dismiss
Recipes

Update a toast — call toast() again with the same id; only the props you pass change. Switching to toast.success(…, { id }) changes the type. This is how loading → success flows work without toast.promise:

const id = toast.loading('Uploading…');
toast.success('Uploaded', { id });

Persist — { duration: Infinity }. Dismiss — toast.dismiss(id), or toast.dismiss() for all. Read active toasts — useSonner() in React, toast.getToasts() outside it.

Links or components in the text — pass a function for the title or description: toast(() => <a href="…">View</a>).

Multiple toasters — give each an id and target with toast('…', { toasterId: 'canvas' }). A toaster with an id renders only toasts targeted at it; a toaster without one renders only untargeted toasts.

Close callbacks — onDismiss fires on close button, swipe, or toast.dismiss(); onAutoClose fires on timeout. They are separate; there is no single "closed" callback.

Styling — the escalation ladder

Climb only as far as the change requires. Exception: if you'd mark more than a few classes !important, go straight to headless — it's the recommended end state.

  1. Defaults — plus richColors on the Toaster for colorful success/error, invert to flip against the theme.
  2. Inline tweaks — toastOptions={{ style: {…} }} on the Toaster for all toasts, or style per toast() call.
  3. Classes on parts — toastOptions={{ classNames: { toast, title, description, actionButton, cancelButton, closeButton } }}. Sonner's injected styles win the cascade, so every class needs !important (Tailwind: !text-red-900). If you're marking more than a few things important, stop — go headless.
  4. Headless — toast.custom() with your own JSX, keeping Sonner's positioning, stacking, and swipe. The recommended approach for a design-system toast: wrap it in your own toast() abstraction. (unstyled: true exists as a halfway house, but headless gives more control for the same effort.)

Icons — swap defaults per-type with the Toaster's icons prop, per-toast with icon, remove with null.

Theme — theme defaults to 'light' and does not track the OS. Pass theme="system", or wire your theme provider: <Toaster theme={resolvedTheme} /> from next-themes.

Troubleshooting
SymptomCause → fix
Toast never appearsNo <Toaster /> mounted, or it unmounted (conditional render, per-page placement). Mount one at the root. If calling from a server action: toast() is client-only — call it with the action's result on the client.
Same toast appears twiceTwo Toasters mounted (layout and page) — keep one. Or toast() fired in an effect under React StrictMode's dev double-invoke — fire from the event handler instead, or pass a stable id so the second call updates rather than duplicates.
Tailwind/CSS classes have no effectDefault styles override them. Mark them !important, or use unstyled / headless (see the ladder above).
Toasts render completely unstyled (common in Astro, view transitions)Sonner's injected stylesheet was lost — import it explicitly in a layout: import 'sonner/dist/styles.css'.
Unstyled inside Shadow DOMStyles land in document.head, not the shadow root. Copy the style tag whose text includes [data-sonner-toaster] into the shadow root.
Toast behind a modal/overlay, or clippedAn ancestor creates a stacking context (transform, filter) or clips it (overflow), or the overlay out-z-indexes the toaster. Move <Toaster /> to the document root, outside any dialog/portal container.
Dark mode ignoredtheme defaults to 'light' — set theme="system" or pass the resolved theme (see Theme above).
Success/error look gray, not green/redThat's the default. Add richColors to the Toaster.
Toast never closesduration: Infinity, or a toast.promise whose promise never settles — the loading toast waits forever.
toast.promise stuck on loadingIt needs a promise (or a function returning one) as its first argument, and the promise must actually resolve/reject.
Swipe-to-dismiss goes the wrong way / doesn't workDirections derive from position. Override with swipeDirections on the Toaster.
Toast shows up in every toasterMultiple toasters need targeting: give each Toaster an id and pass toasterId in the toast() call.
Toasts too close to the screen edge on mobileoffset (desktop, default 24px) and mobileOffset (<600px, default 16px) — numbers, CSS strings, or per-side objects.
Install

The official shadcn/ui skill: project-aware rules and CLI workflows for adding, composing, styling and updating shadcn components, applying presets, and turning a DESIGN.md into a themed design system.

Skill: GSAP React

by GreenSock

New

GreenSock's official skill for using GSAP in React and Next.js: the useGSAP() hook with scoped selectors and automatic cleanup, refs for targets, contextSafe callbacks, gsap.context() in useEffect, and SSR-safe usage.

Browse all skills →