How old the data on screen is, and whether the app's cache is fetching it again: "Updated 3 minutes ago", with a small icon that turns while it refreshes. The data stays in view while the refresh runs, so the line is the only thing that changes. The icon keeps its room while idle, so the line holds its width. The age keeps itself current. The root carries data-ouro-refreshing and holds a <time> with the exact instant, so an agent reads what the person sees. The app's cache stores the data and says when it was fetched; Freshness draws what it reports.
Install
Add Freshness from Ouro UI to this app. Read https:// ui.ouroboros.bot/ docs/ freshness.md first and follow it.Or by hand. Once per app, with Tailwind CSS v4 and an @/* path alias (Ouro HX is built on Base UI, so --base base; skip -t in an existing app):
npx shadcn@latest init --base base --preset nova --yes --no-monoreponpx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823Then the component (Installing):
npx shadcn@latest add ourostack/ouro-ui/freshness#v1.3.823Or, with the @ouro namespace set up:
npx shadcn@latest add @ouro/ouro-base @ouro/freshnessIts tests, stories and Playwright spec are optional. They need Vitest 4.1.11 or later, and from v0.8.0 never change a version your app has (Testing):
npx shadcn@latest add ourostack/ouro-ui/freshness#v1.3.823 ourostack/ouro-ui/freshness-tests#v1.3.823import { Freshness } from "@/components/ouro/freshness/freshness";Paths use shadcn's default @/ alias; the CLI rewrites them to yours.
Example
<Freshness updatedAt={query.dataUpdatedAt} refreshing={query.isFetching} />Use instead when
- Use
SyncStatusinstead for where the person's own changes are, andRelativeTimefor the age of a single item.
Props
Type: FreshnessProps.
className- Type:
string - Layout only: margins, placement (
mt-3). Appearance classes warn in development. labels- Type:
FreshnessLabels - The words, for another language.
locale- Type:
Intl.LocalesArgument - Default: the reader's
- The language and region of the age.
ref- Type:
Ref<HTMLSpanElement> - Reaches the rendered element.
refreshing- Type:
boolean - Default:
false truewhile the app's cache fetches again and the old data still shows. A small icon turns and the root carriesdata-ouro-refreshing.updatedAt(required)- Type:
Date | string | number - When the data on screen was last fetched: a
Date, an ISO string or a timestamp in milliseconds. The app's cache reports it.
Native attributes
Also accepts the attributes in React's HTMLAttributes (id, aria-*, event handlers), passed to the rendered element, except those named on this page.
Don't use
These are not props. Passing one fails the type check with the fix in the error, and in development a console message names the fix.
isFetching: Not a prop. Ouro UI saysrefreshing:<Freshness refreshing={query.isFetching} />.lastUpdated: Not a prop. Ouro UI saysupdatedAt:<Freshness updatedAt={query.dataUpdatedAt} />.
className is for layout only
Pass margins, width and grid placement (mt-4, w-full, col-span-2).
Appearance comes from props, not classes. In development, a class that sets appearance logs one warning per component instance, naming the prop to use instead. A class sets appearance when, after its variants (hover:, sm:) and any ! are removed, it starts with bg-, text-, border-, rounded-, shadow-, font-, ring-, from-, via-, to-, fill- or stroke-, or is border, rounded, shadow or ring, or has a dark: variant. Text wrapping, overflow and table layout classes (text-wrap, text-ellipsis, border-collapse) are layout and do not warn.
Alignment classes (text-center) warn too: set alignment on a parent element.
Types
FreshnessLabels
The words Freshness says, for apps in other languages.
interface FreshnessLabels {
/** The age line, with `{age}` where the time goes ("3 minutes ago"). @default "Updated {age}" */
updated?: string | undefined;
/** What screen readers hear while the app's cache refreshes. @default "Refreshing" */
refreshing?: string | undefined;
}
