<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/1rnzomcsk" -->

---
title: Building a toast component | daily.dev
description: Sonner is a React toast library downloaded 7M+ times weekly. Its success stems from unique stacking animations using CSS transitions instead of keyframes for...
canonical: https://daily.dev/posts/1rnzomcsk
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Building a toast component | daily.dev
og:description: Sonner is a React toast library downloaded 7M+ times weekly. Its success stems from unique stacking animations using CSS transitions instead of keyframes for...
og:url: https://daily.dev/posts/1rnzomcsk
og:image: https://api.daily.dev/og/posts/1rnzomcSk.png
og:image:alt: Post cover image
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Building a toast component

**[Anja P](https://daily.dev/sources/wvjsfjtde63pxqfasmxfo)** · [@anjapcodes](https://daily.dev/anjapcodes) · 4 upvotes · 0 comments

## Summary

Sonner is a React toast library downloaded 7M+ times weekly. Its success stems from unique stacking animations using CSS transitions instead of keyframes for smooth interruption, momentum-based swipe gestures, and an Observer Pattern for state management that avoids React Context. Key implementation details include dynamic height calculations for stacking, velocity-based dismissal, tab visibility detection to pause timers, and pointer capture for consistent drag behavior. The library prioritizes developer experience with a simple API and comprehensive documentation.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://emilkowal.ski/ui/building-a-toast-component>

## Similar posts on daily.dev

- [Laravel Starter Kits Now Include Toast Notifications](https://daily.dev/posts/laravel-starter-kits-now-include-toast-notifications-zrobngcgd) · Laravel News · 23 upvotes · 0 comments
- [Toast Notifications](https://daily.dev/posts/toast-notifications-sqer3gbxv) · Larablog · 1 upvotes · 0 comments
- [React ViewTransition vs. Motion: Comparing animation approaches](https://daily.dev/posts/react-viewtransition-vs-motion-comparing-animation-approaches-8boanxhvn) · LogRocket · 20 upvotes · 1 comments
- [Tailwind duct-tape wallets](https://daily.dev/posts/tailwind-duct-tape-wallets-phluy8lgq) · Bytes by ui.dev · 2 upvotes · 0 comments

---

Tags: [#react](https://daily.dev/tags/react), [#css](https://daily.dev/tags/css), [#ux](https://daily.dev/tags/ux)

[View this post on daily.dev](https://daily.dev/posts/1rnzomcsk)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/1rnzomcsk","headline":"Building a toast component","text":"Shared: Building a toast component","url":"https://daily.dev/posts/1rnzomcsk","datePublished":"2026-01-23T15:50:10.044Z","dateModified":"2026-01-23T15:50:10.047Z","author":{"@type":"Person","name":"Anja P","url":"https://daily.dev/anjapcodes","image":"https://media.daily.dev/image/upload/s--M_c0s8Ky--/f_auto/v1721658650/avatars/avatar_WVJSfJtDe63PxQFAsmXFO","description":"< Self-taught front-end developer + coding bootcamp  grad, tech enthusiast + design lover + poet />","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":51660}},"image":"https://media.daily.dev/image/upload/s--2-1xRawN--/f_auto/v1722860399/public/Placeholder%2011","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/bFSfq18FW"},"isPartOf":{"@type":"WebPage","url":"https://daily.dev/sources/wvjsfjtde63pxqfasmxfo","name":"Anja P"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Anja P","item":"https://daily.dev/sources/wvjsfjtde63pxqfasmxfo"},{"@type":"ListItem","position":3,"name":"Building a toast component"}]}
```

