Skip to Content
zjkm-ui
Components

Timed Toast

A toast with a countdown bar that pauses on hover.

Props
5000ms
<TimedToast open={open} title="Upload complete" onClose={close} />

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/timed-toast.json
import { TimedToast } from "@/components/timed-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 with a bar along its edge that counts down the time left. Hovering or focusing it pauses the countdown. It sits fixed in the bottom-right corner of the window and announces itself politely to screen readers.

import { TimedToast } from "@/components/timed-toast";

export function UploadDone({ open, onClose }: { open: boolean; onClose: () => void }) {
  return <TimedToast open={open} title="Upload complete" description="report.pdf" onClose={onClose} />;
}

Props

PropTypeDefaultDescription
openbooleanShows the toast.
titlestringThe headline.
descriptionstringA second line.
onClose() => voidCalled when time runs out or it's dismissed.
durationnumber5000Milliseconds before it closes.
colorstring"#818cf8"Colour of the countdown bar.

With reduced motion, the bar is hidden but the toast still closes on time.

On this page