/officialunofficial-skills:ask-sonnerfrom Official Unofficial Skills
Guides work with Sonner, the React toast library: mounting the Toaster, choosing the right toast() call, promise and loading toasts, updating, dismissing and persisting, styling, theming, icons, positioning and multiple toasters.
Ships in Official Unofficial Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Answer Sonner questions from this file first. Read API.md when you need an exact prop name, type, or default.
Sonner has two parts.
<Toaster />, mounted once, as near the root as possible. In Next.js that is layout.tsx, and it works inside server components. A Toaster rendered per page or behind a condition goes missing, and a second mounted Toaster shows every toast twice.toast() called from client code: event handlers, effects, callbacks. It is a plain function with no hook or provider. It does nothing on the server, so a server action returns its result and the client code that receives it calls toast().import { Toaster } from 'sonner'; // once, in the layout
import { toast } from 'sonner'; // anywhere on the client
| Goal | Call |
|---|---|
| Plain message | toast('Title'), with { description } for a second line |
| Message with a status icon | toast.success(), toast.error(), toast.info(), toast.warning() |
| Spinner while you track state yourself | toast.loading(), then update it by id |
| Loading that resolves with a promise | toast.promise(promise, { loading, success, error }). success and error may be functions of the resolved value or the error |
| A button in the toast | { action: { label, onClick } }. The click closes the toast unless onClick calls event.preventDefault(). cancel is the secondary button |
| Custom JSX inside the default shell | toast(<jsx />) |
| Custom JSX with no Sonner styles | toast.custom((t) => <jsx />). t is the id, for dismissing |
Update a toast. Call toast() again with the same id. Only the props you pass change, and a typed call changes the type.
const id = toast.loading('Uploading...');
toast.success('Uploaded', { id });
Persist. Pass { duration: Infinity }.
Dismiss. toast.dismiss(id) closes one toast. toast.dismiss() closes all.
Read active toasts. Use useSonner() in React and toast.getActiveToasts() outside it.
Links or components in the text. Pass a function as the title or description: toast(() => <a href="/doc">View</a>).
Multiple toasters. Give each Toaster an id and target one with toast('Saved', { toasterId: 'canvas' }). A toast with no toasterId renders in every Toaster.
Close callbacks. onDismiss fires for the close button and for a swipe. onAutoClose fires on timeout. No single callback covers both.
Use the lowest level that achieves the change. For a design-system toast, go straight to level 4.
richColors on the Toaster for coloured success and error toasts, or invert to flip against the theme.toastOptions={{ style }} on the Toaster covers every toast. style on a toast() call covers one.toastOptions={{ classNames: { toast, title, description, actionButton, cancelButton, closeButton } }}. Sonner's injected styles win the cascade, so each class needs !important (Tailwind: !text-red-900). If more than a few classes need it, move to level 4.toast.custom() renders your JSX and keeps Sonner's positioning, stacking, and swipe. Wrap it in your own toast() function. unstyled: true is a halfway option that gives less control for the same effort.Icons. The Toaster's icons prop replaces the default per type. icon on a call replaces one. null removes it.
Theme. theme defaults to 'light' and does not follow the OS. Pass theme="system", or pass the resolved theme from your provider, such as <Toaster theme={resolvedTheme} /> with next-themes.
| Symptom | Cause and fix |
|---|---|
| Toast never appears | No Toaster is mounted, or it unmounted. Mount one at the root. In a server action, return the result and call toast() on the client |
| Toast appears twice | Two Toasters are mounted, often layout and page. Keep one. Or an effect fired twice under React StrictMode in development: call from the event handler, or pass a stable id so the second call updates the first |
| Tailwind or CSS classes do nothing | The default styles override them. Add !important, or go headless |
| Toasts fully unstyled (common in Astro and with view transitions) | The injected stylesheet was lost. Import it in a layout: import 'sonner/dist/styles.css' |
| Unstyled inside Shadow DOM | Styles go to document.head. Copy the style tag whose text contains [data-sonner-toaster] into the shadow root |
| Toast behind a modal, or clipped | An ancestor creates a stacking context (transform, filter, overflow), or the overlay has a higher z-index. Move the Toaster to the document root, outside any dialog or portal container |
| Dark mode ignored | theme defaults to 'light'. Set theme="system" or pass the resolved theme |
| Success and error look gray | That is the default. Add richColors |
| Toast never closes | duration: Infinity, dismissible: false, or a toast.promise whose promise never settles |
toast.promise stuck on loading | The first argument must be a promise, or a function that returns one, and it must resolve or reject |
| Swipe goes the wrong way or does nothing | Swipe directions follow position. Set swipeDirections on the Toaster |
| Toast shows in every Toaster | Give each Toaster an id and pass toasterId in the call |
| Toasts too close to the edge on mobile | offset (default 32px) and mobileOffset (below 600px wide, default 16px). Each takes a number, a CSS string, or a per-side object |
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub officialunofficial/skills --plugin officialunofficial-skills85 skills in this plugin
/alignmentMeasures a running page for edges, gaps, centres and radii that miss by a pixel or two, judges visual weight, and returns a numbered report with proof./animateBuilds a web animation from scratch and writes the code. Decides in order whether it should animate at all, its purpose, the tool, the properties, the easing and duration or spring, how it interrupts and exits, and reduced motion. Use when asked to animate something, add motion, build a transition, or make a component feel alive. For React Native or Expo use animate-expo. To critique existing motion use review-animations. To audit a whole codebase use improve-animations./animate-expoBuilds animations in React Native and Expo with Reanimated, Gesture Handler, Expo Router and expo-haptics. Decides in order whether to animate, which tool, which properties, spring or timing, and how to stay on the UI thread. Use when animating anything in an Expo app, adding gestures, sheets, screen transitions, press feedback or haptics, or fixing motion that stutters on a device. For web animation use `animate`./animation-performanceDiagnoses and fixes web animations that drop frames. Covers the layout, paint and composite pipeline, cheaper property swaps, CSS and WAAPI against requestAnimationFrame, the accelerated path in Motion, React re-renders per frame, inherited CSS variables, blur cost, and when will-change helps. Use when an animation is janky, choppy or stutters, when choosing which property to animate, or when reaching for will-change or GPU layers. For easing, duration or whether to animate at all, use animate./animation-vocabularyNames a web animation or motion effect from a loose description, for example "the bouncy thing when a popover opens" is Pop in and "the iOS scroll that resists and snaps back" is Rubber-banding. Use when the user asks "what is it called when..." or describes a motion effect and wants the right word to give a designer or an agent. It names effects. It does not design or build them./apple-designApplies Apple's approach to fluid, physical interfaces on the web. Use when building or reviewing gesture-driven UI, spring animation, drag, swipe or sheet interactions, momentum, interruptible transitions, rubber-banding, translucent materials and depth, type tracking and leading, reduced motion, or when a design needs Apple's design principles as a frame.