Patch UI

TimeAgo

Relative time display ("3m ago", "2d ago"). Renders an absolute date during SSR / initial hydration and swaps to the relative string after mount, avoiding hydration mismatches.

Defaults to mono numerals since timestamps are always numeric data.

$npx shadcn add @patchui/time-ago
Just now:
5 min ago:
3 hours ago:
2 days ago:
Last week:
Sans variant:

Usage

import { TimeAgo } from "@patchui/react";
 
<TimeAgo dateStr={post.publishedAt} />

Props

  • dateStr - ISO date string
  • fallback - string rendered during SSR (defaults to formatted absolute date)
  • variant - "mono" (default) or "sans"