Status Timestamp
openstatus/status-timestampFreeBlock
Interactive timestamp display with tooltip (simple) or hover-card (rich) variants showing multiple timezone formats
Install it
npx shadcn@latest add https://openstatus.dev/r/status-timestamp.jsonSource
1"use client";23import { UTCDate } from "@date-fns/utc";4import {5 HoverCard,6 HoverCardContent,7 HoverCardTrigger,8} from "@/components/ui/hover-card";9import {10 Tooltip,11 TooltipContent,12 TooltipProvider,13 TooltipTrigger,14} from "@/components/ui/tooltip";15import { useCopyToClipboard } from "@/hooks/use-copy-to-clipboard";16import { useMediaQuery } from "@/hooks/use-media-query";17import { cn } from "@/lib/utils";18import type { HoverCardContentProps } from "@radix-ui/react-hover-card";19import { format, formatDistanceToNowStrict } from "date-fns";20import { Check, Copy } from "lucide-react";21import { useEffect, useState } from "react";2223type BaseProps = {24 date: Date;25 variant?: "simple" | "rich";26 className?: string;27};2829type SimpleVariantProps = BaseProps &30 React.ComponentProps<typeof TooltipTrigger> & {31 variant?: "simple";32 };3334type RichVariantProps = BaseProps &35 React.ComponentProps<typeof HoverCardTrigger> & {36 variant: "rich";37 side?: HoverCardContentProps["side"];38 align?: HoverCardContentProps["align"];39 alignOffset?: HoverCardContentProps["alignOffset"];40 sideOffset?: HoverCardContentProps["sideOffset"];41 };4243type StatusTimestampProps = SimpleVariantProps | RichVariantProps;4445/**46 * StatusTimestamp - Polymorphic timestamp display component with timezone support47 *48 * A flexible timestamp component that can display dates in two variants:49 * - **simple**: Shows a tooltip on hover with the formatted date (default)50 * - **rich**: Shows a hover card with local timezone, UTC, and relative time, plus copy-to-clipboard51 *52 * The component automatically detects the user's timezone using `Intl.DateTimeFormat()`53 * and displays the date in both the local timezone and UTC. The rich variant includes54 * a live-updating relative time display ("2 minutes ago") that refreshes every second55 * while the hover card is open.56 *57 * Touch device support is built-in for the rich variant, toggling the hover card on tap58 * instead of requiring hover.59 *60 * @param date - The date to display61 * @param variant - Display style: "simple" for tooltip, "rich" for hover card with details62 * @param side - (rich variant only) Placement of the hover card: "top" | "right" | "bottom" | "left"63 * @param align - (rich variant only) Alignment of the hover card: "start" | "center" | "end"64 * @param alignOffset - (rich variant only) Pixel offset for alignment (default: -4)65 * @param sideOffset - (rich variant only) Pixel offset from the trigger66 *67 * @example68// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from openstatus
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Status Bannerstatus-banner | openstatus | Blocks | Free | no deps | |
| Status Barstatus-bar | openstatus | Blocks | Free | 1 dep | |
| Status Blank Statesstatus-blank | openstatus | Blocks | Free | no deps | |
| Status Calendarstatus-calendar | openstatus | Blocks | Free | 3 deps | |
| Status Page Chromestatus-chrome | openstatus | Blocks | Free | no deps | |
| Status Page (Complete)status-complete | openstatus | Blocks | Free | no deps | |
| Status Componentstatus-component | openstatus | Blocks | Free | 2 deps | |
| Status Component Groupstatus-component-group | openstatus | Blocks | Free | no deps |
