NK

Search

Search pages, posts, and components

All components

Countdown Timer

Data Display

Counts down from a duration and fires a callback at zero.

02:05

Installation

Add it with the shadcn CLI:

$pnpm dlx shadcn@latest add https://nawalkattel.com.np/r/countdown-timer.json
Or install manually
  1. 1. Install dependencies

    pnpm add clsx tailwind-merge
  2. 2. Copy the component source into components/library/countdown-timer.tsx

Props

PropTypeDefaultDescription
secondsnumber60Starting duration in seconds.
onComplete() => void - Fires once the timer reaches zero.

Accessibility

  • Renders as text, so the remaining time is readable by assistive tech.
  • Tabular numerals keep the width stable as digits change.
  • Clears its timeout on unmount and between ticks.

Dependencies

clsxtailwind-merge