Components
- Accordion
- Action Bar
- Alert Dialog
- Alert
- Announcement
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Bottom Navigation
- Breadcrumb
- Button Group
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Circular Progress
- Circular Slider
- Clipboard
- Collapsible
- Color Picker
- Combobox
- Command
- Context Menu
- Data List
- Date Picker
- Dialog
- Drawer
- Editable
- Field
- File Upload
- Float
- Floating Panel
- Frame
- Hint
- Hover Card
- Image Cropper
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Link Overlay
- Listbox
- Marquee
- Menu
- Native Select
- Number Input
- Pagination
- Popover
- Progress
- Prose
- QR Code
- Radio Group
- Rating
- Resizable
- Scroll Area
- Segment Group
- Select
- Separator
- Sheet
- Sidebar
- Signature Pad
- Skeleton
- Skip Nav
- Slider
- Spinner
- Status
- Steps
- Switch
- Table
- Tabs
- Textarea
- Timer
- Toast
- Toggle Group
- Toggle Tooltip
- Toggle
- Tooltip
- Tour
- Tree View
00
days:
00
hours:
40
minutes:
00
secondsInstallation
pnpm dlx shadcn@latest add https://shark.vini.one/r/timer.json
Usage
import { Timer, TimerArea, TimerItem, TimerSeparator, TimerControl, TimerActionTrigger, } from "@/components/ui/timer";
<Timer targetMs={3600000} startMs={2400000}> <TimerArea> <TimerItem type="hours" /> <TimerSeparator>:</TimerSeparator> <TimerItem type="minutes" /> <TimerSeparator>:</TimerSeparator> <TimerItem type="seconds" /> </TimerArea> <TimerControl> <TimerActionTrigger action="start">Start</TimerActionTrigger> <TimerActionTrigger action="pause">Pause</TimerActionTrigger> </TimerControl> </Timer>
Examples
Countdown
Create a countdown by setting countdown to true and startMs to the initial duration.
05
minutes:
00
secondsInterval
Use the interval prop to control update frequency.
00
seconds.
000
msEvents
Listen to onTick and onComplete for timer events.
00
minutes:
00
secondsPomodoro
Alternate between work and break sessions using onComplete.
Work Session
25
minutes:
00
secondsAPI Reference
Timer
| Prop | Type | Default |
|---|---|---|
targetMs | number | 0 |
startMs | number | 0 |
countdown | boolean | false |
interval | number | 1000 |
onTick | (details: TickDetails) => void | - |
onComplete | () => void | - |
TimerArea
| Prop | Type | Default |
|---|---|---|
className | string | - |
TimerItem
| Prop | Type | Default |
|---|---|---|
type | "days" | "hours" | "minutes" | "seconds" | "milliseconds" | "seconds" |
TimerSeparator
| Prop | Type | Default |
|---|---|---|
className | string | - |
TimerControl
| Prop | Type | Default |
|---|---|---|
className | string | - |
TimerActionTrigger
| Prop | Type | Default |
|---|---|---|
action | "start" | "pause" | "resume" | "reset" | "start" |
For a complete list of props, see the Ark UI documentation.