<!-- Generated by scripts/gen-docs.mts from the JSDoc in registry/. Do not edit; run `pnpm run docs`. -->

# Freshness

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

Once per app, with Tailwind CSS v4 and an `@/*` path alias (skip `init` in an existing shadcn app), then the component:

```sh
npx shadcn@latest init --base base --preset nova --yes --no-monorepo
npx shadcn@latest add ourostack/ouro-ui/ouro-base#v1.3.823
npx shadcn@latest add ourostack/ouro-ui/freshness#v1.3.823
```

More: [Installing](https://ui.ouroboros.bot/docs/installing.md).

```tsx
import { Freshness } from "@/components/ouro/freshness/freshness";
```

## Example

```tsx
<Freshness updatedAt={query.dataUpdatedAt} refreshing={query.isFetching} />
```

## Use instead when

- Use `SyncStatus` instead for where the person's own changes are, and `RelativeTime` for the age of a single item.

## Props

Type: `FreshnessProps`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `className` | `string` |  | Layout only: margins, placement (`mt-3`). Appearance classes warn in development. |
| `labels` | `FreshnessLabels` |  | The words, for another language. |
| `locale` | `Intl.LocalesArgument` | the reader's | The language and region of the age. |
| `ref` | `Ref<HTMLSpanElement>` |  | Reaches the rendered element. |
| `refreshing` | `boolean` | `false` | `true` while the app's cache fetches again and the old data still shows. A small icon turns and the root carries `data-ouro-refreshing`. |
| `updatedAt` (required) | `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 says `refreshing`: `<Freshness refreshing={query.isFetching} />`.
- `lastUpdated`: Not a prop. Ouro UI says `updatedAt`: `<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.

```ts
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;
}
```
