Components
Swipe Toast
A toast you can swipe away.
<SwipeToast open={open} title="Conversation archived" onClose={close} />Installation
npx shadcn@latest add https://ui.zjkm.tech/r/swipe-toast.jsonimport { SwipeToast } from "@/components/swipe-toast"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
A toast you can swipe or drag sideways to dismiss. It fades as you drag and springs back if you don't go far enough. The Dismiss button does the same for keyboard and screen reader users. It sits fixed in the bottom-right corner of the window and announces itself politely to screen readers.
import { SwipeToast } from "@/components/swipe-toast";
export function Archived({ open, onClose }: { open: boolean; onClose: () => void }) {
return <SwipeToast open={open} title="Conversation archived" onClose={onClose} />;
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | Shows the toast. | |
title | string | The headline. | |
description | string | A second line. | |
onClose | () => void | Called when it's swiped away or dismissed. | |
threshold | number | 100 | Pixels of swipe that dismiss it. |
With reduced motion, a full swipe closes it at once instead of flying it out.