Toasts with real spring physics.
One toast that morphs in place. No dependencies. React, Svelte, Vue or plain DOM.
- Morphs by default. New calls reuse a quick toast; errors and other held toasts keep their place unless you choose
held: 'replace'. - Real springs. Size, shape and text move on a spring solver, so interrupting an animation keeps its momentum.
- No stylesheet. Styles are injected from JavaScript. Nothing to import.
- Light, dark and system themes, six positions, right-to-left support.
- Easy to restyle. Colors and corner radius are CSS variables.
- Rich content. Description, avatar, buttons, progress bar, a countdown line, small trailing text.
- Accessible by default. Persistent live regions, keyboard dismiss,
prefers-reduced-motion. - Optional sound. A soft built-in tone per status, or plug in your own.
- Strict TypeScript, ESM and CommonJS builds.
npm i @yusufceng1z/ding-react # React 18+
npm i @yusufceng1z/ding-svelte # Svelte 5
npm i @yusufceng1z/ding-vue # Vue 3 and Nuxt
npm i @yusufceng1z/ding # plain DOMEach framework package depends on the small @yusufceng1z/ding core, so you install only one.
Using shadcn/ui? Ding is in the shadcn registry directory, so one command installs the React package and adds a ding-toaster.tsx wrapper:
npx shadcn@latest add @ding/dingThe Ding skill gives Claude Code, Codex, Cursor, GitHub Copilot, and other Agent Skills-compatible tools framework setup and guidance on promises, progress, and toast actions.
Run the installer from your app with Node.js 22.20 or newer, then select your coding agent.
npx skills add YusufCeng1z/ding --skill dingAdd --global to use the skill across projects. For manual installation, copy the ding skill directory into your agent's project skills directory. In Claude Code, that directory is .claude/skills/ and the command is /ding.
For Claude chat, create an uploadable ZIP from a clone of the Ding repository.
git archive --format=zip --output=ding-skill.zip HEAD:.agents/skills dingUpload ding-skill.zip under Customize → Skills. Claude's upload guide
Render the toaster once, then call toast from anywhere.
Guides for React, Svelte, Vue and Nuxt, and plain JavaScript.
React
import { Toaster, toast } from '@yusufceng1z/ding-react';
export default function App() {
return (
<>
<Toaster position="top-center" theme="system" />
<button onClick={() => toast.success('Saved')}>Save</button>
</>
);
}Works in the Next.js App Router as is: the package ships "use client", so Toaster can go straight into app/layout.tsx. Call toast.configure from a client component, in an effect. See the Next.js guide.
Svelte 5
<script>
import { Toaster, toast } from '@yusufceng1z/ding-svelte';
</script>
<Toaster position="top-center" theme="system" />
<button onclick={() => toast.success('Saved')}>Save</button>Vue 3
<script setup>
import { Toaster, toast } from '@yusufceng1z/ding-vue';
</script>
<template>
<Toaster position="top-center" theme="system" />
<button @click="toast.success('Saved')">Save</button>
</template>Toaster renders nothing in place and mounts in onMounted, so server rendering is safe. In Nuxt, put it in app.vue and call toast from client code.
Plain DOM
import { mountToaster, toast } from '@yusufceng1z/ding';
mountToaster({ position: 'top-center' });
toast.success('Saved');toast.success('Saved');
toast.error('Payment failed', { description: 'Card declined' });
toast.warning('Storage almost full');
toast.info('New version available');
toast.loading('Uploading…');Toast show calls return a caller ID; toast.promise() returns the supplied promise.
toast.promise(save(), {
loading: 'Saving…',
success: 'Saved',
error: (err) => `Could not save: ${err.message}`,
});
const id = toast.loading('Uploading photo…', { progress: 0 });
toast.update(id, { progress: 0.6 });
toast.update(id, { type: 'success', title: 'Photo uploaded', progress: null });Only the newest caller can update the shared toast, so a slow request that finishes late cannot overwrite a newer message.
A synchronous onClick may return a patch to morph the toast in place. An async action closes on click; show its outcome as a separate toast, or use toast.promise() for a loading-to-result morph.
toast.success('Message deleted', {
action: {
label: 'Undo',
onClick: () => {
restore();
return { type: 'info', title: 'Restored' };
},
},
});| Option | Description |
|---|---|
description |
Second line of text |
action |
{ label, onClick }, the main button |
secondary |
{ label, onClick }, a quieter button beside the action |
image |
Avatar or thumbnail URL, replaces the status icon |
meta |
Small trailing text, such as now or ⌘V |
progress |
0 to 1, draws a thin bar at the bottom |
duration |
Milliseconds before it closes. 0 keeps it until dismissed. Default 5000 |
id |
Reuse an id so repeated calls from one place stay one caller |
By default, errors, loading toasts and toasts with a button stay until dismissed. Hover, keyboard focus and a hidden tab pause the countdown on timed toasts. Repeating the same toast adds a counter (×2).
toast.configure({
position: 'bottom-right', // top-left, top-center, top-right, bottom-left, bottom-center, bottom-right
theme: 'dark', // system, light, dark
sound: true,
volume: 0.5,
});
toast.dismiss(id); // one toast
toast.dismiss(); // alldismiss(id) uses the id returned by a toast call. If a newer call takes over that toast, dismissing the old id does nothing. Custom renderers should use toast.close(item.id) to close the visible toast by its ToastItem.id; this also works after a takeover.
A toast is held when it stays until dismissed: an error, a toast with a button, or one with duration: 0. A loading toast is not held, because it is about to turn into its result. held decides what happens when another toast arrives while a held toast is on screen:
| Value | Behavior |
|---|---|
'list' (default) |
The held toast keeps its place. Quick toasts appear next to it, and a new held toast takes over the quick one. |
'queue' |
New toasts wait in order and show one after another once the held toast is gone. |
'replace' |
A new toast morphs the one on screen, held or not. This is how 0.0.5 behaved. |
toast.configure({ held: 'replace' }); // always one toastSet it with toast.configure, or pass held to mountToaster in plain DOM.
Colors and corner radius are CSS variables. Set them in your own stylesheet and they apply to every toast, in any framework:
:root .tst-viewport {
--tst-radius: 8px;
--tst-bg: #1e3a8a;
--tst-fg: #fff;
--tst-success: #16a34a;
}| Variable | Default | Controls |
|---|---|---|
--tst-radius |
22px |
Corner radius. The default makes a pill |
--tst-bg |
light-dark(#fff, #0c0c0d) |
Background |
--tst-fg |
light-dark(#0f0f13, #fafafa) |
Text |
--tst-success |
light-dark(#12a36b, #4ade80) |
Success icon |
--tst-error |
light-dark(#e5484d, #f87171) |
Error icon |
--tst-warning |
light-dark(#c77d00, #fbbf24) |
Warning icon |
--tst-info |
light-dark(#2f7de1, #60a5fa) |
Info icon |
The defaults follow the theme through light-dark(). A single value applies to both themes. To keep them apart, write your own: --tst-bg: light-dark(#fff, #111).
More hooks, for when colors and radius are not enough:
| Variable | Default | Controls |
|---|---|---|
--tst-size |
44px |
Height of the pill, and the width of the icon circle |
--tst-pad |
16px |
Distance from the screen edge |
--tst-shadow |
built in | Shadow around the toast |
--tst-enter-scale |
built in | How small the toast starts when it arrives |
The font comes from .tst-viewport, so set font-family and font-size there.
Filled toasts. Each toast exposes --fill (surface), --on (text, buttons, close button, focus ring) and --c (icon color) per status. Override them to fill the whole toast with its status color:
.tst-viewport .tst[data-type=error] { --fill: #e5484d; --on: #fff; --c: #fff; }
.tst-viewport .tst[data-type=success] { --fill: #12a36b; --on: #fff; --c: #fff; }Light and dark. Ding follows the system by default. If your site has its own theme switch, such as a .dark class, pass the current theme: <Toaster theme={theme} /> or toast.configure({ theme }). Give a color two values with light-dark(), and it picks the one for the active theme:
.tst-viewport .tst[data-type=error] { --fill: light-dark(#dc2626, #7f1d1d); --on: #fff; --c: #fff; }One toast, one style. Pass className and style it as .tst.your-class. toast.update(id, { className: null }) removes it.
toast.success('Saved', { className: 'big' });Springs. Retune the three motions. Each takes { stiffness, damping }; leave one out to keep its default (enter 320/26, morph 340/27, stack 400/36). Applies to toasts shown afterwards.
toast.configure({ springs: { enter: { stiffness: 220, damping: 14 } } });Icons. Replace a status icon with SVG path strings on a 24×24 grid, drawn as strokes. The first path is the outer ring. Keep three paths for warning and info, since their animations target the second and third.
toast.configure({ icons: { success: ['M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18', 'M8 12l3 3 5-6'] } });Off by default. With sound: true each status plays its own soft tone: success rises, error falls, warning double-taps, info is a single note. Loading is silent and progress updates never make a sound. Browsers keep audio locked until a click or key press.
To use your own sounds, pass a function. It receives success, error, warning, info or loading:
toast.configure({ sound: (type) => mySounds.play(type) });- Messages go through persistent live regions: errors are assertive, everything else is polite.
Escdismisses.Alt+Tmoves focus into the toast.- Respects
prefers-reduced-motion. - Mirrors automatically on right-to-left pages.
The notifications region and the close button have English accessible names by default. Pass your own strings to localize them; keys you leave out keep their default.
toast.configure({
labels: {
region: 'Notifications',
dismiss: 'Fermer la notification',
},
});<Toaster labels={{ dismiss: 'Fermer la notification' }} /> does the same in React, Svelte and Vue, and mountToaster({ labels }) in plain DOM.
Styles are injected as one <style> element. If your CSP blocks inline styles, pass the page's nonce:
<Toaster nonce={nonce} /> {/* React, Svelte, Vue (:nonce="nonce") */}mountToaster({ nonce }); // plain DOMPer-toast values are set through the DOM, which CSP allows, so only the stylesheet needs the nonce.
| Package | Description |
|---|---|
@yusufceng1z/ding |
Springs, timers, store, sound and the plain DOM renderer |
@yusufceng1z/ding-react |
React renderer |
@yusufceng1z/ding-svelte |
Svelte 5 renderer |
@yusufceng1z/ding-vue |
Vue 3 renderer |
The core owns all behavior. The framework packages only render.
pnpm install
pnpm test # unit tests
pnpm typecheck
pnpm build # build all packages
pnpm dev # docs and demo siteThe Astro docs site lives in apps/docs and requires Node.js 22.23.4 or newer. Run pnpm --filter docs build to compile the site and verify its public URLs and SEO metadata. A machine-readable summary is in apps/docs/public/llms.txt.
