Components
Relative Time Card
A hover card that displays relative time relative to local time with timezone information.
Basic usage
Different variants
Multiple timezones
Custom trigger
Different positions
Installation
CLI
Manual
Install the following dependencies:
Copy and paste the following code into your project.
Examples
With Multiple Timezones
With Variants
Style variants
Custom styling
Hover card positions
Custom trigger
API Reference
RelativeTimeCard
The main component that displays relative time with hover functionality.
Prop | Type | Default |
---|---|---|
date | string | number | Date | - |
timezones | string[] | ["UTC"] |
updateInterval | number | 1000 |
variant | "default" | "subtle" | "ghost" | "default" |
open | boolean | false |
defaultOpen | boolean | false |
onOpenChange | (open: boolean) => void | - |
openDelay | number | 500 |
closeDelay | number | 300 |
side | "top" | "right" | "bottom" | "left" | "bottom" |
sideOffset | number | 0 |
align | "center" | "start" | "end" | "center" |
alignOffset | number | 0 |
avoidCollisions | boolean | true |
collisionBoundary | Element | Boundary[] | [] |
collisionPadding | number | Partial<Record<"top" | "right" | "bottom" | "left", number>> | 0 |
asChild | boolean | false |
Data Attribute | Value |
---|---|
[data-state] | "open" | "closed" |
Accessibility
Keyboard Interactions
Key | Description |
---|---|
Tab | Opens/closes the relative time card. |
Enter | Opens the relative time card if closed. |