Skip to Content
zjkm-ui
Components

Swipe Toast

A toast you can swipe away.

Props
<SwipeToast open={open} title="Conversation archived" onClose={close} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/swipe-toast.json
import { 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

PropTypeDefaultDescription
openbooleanShows the toast.
titlestringThe headline.
descriptionstringA second line.
onClose() => voidCalled when it's swiped away or dismissed.
thresholdnumber100Pixels of swipe that dismiss it.

With reduced motion, a full swipe closes it at once instead of flying it out.

On this page