Field History

Field History is a copy-paste React component that stops overwrote teammate's change unknowingly before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/field-history
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsOverwrote teammate's change unknowingly

Was this component page useful?

How do I install Field History?

pnpm dlx shadcn@latest add @bollard/field-history

The files land in your project. They're yours to edit.

What input mistakes does Field History catch?

  • Recent changes by someone else (within recentFor)
  • The previous value and who changed it
  • Reverts that would also replace your unsaved edit
  • Regret after a revert, with Undo

What props does Field History accept?

FieldHistory props
PropTypeDefault
label* (required)

The field's label.

string—
htmlFor

The id of the field's input, so the label is a real `<label>`.

string—
children* (required)

The field itself (an input, select...).

React.ReactNode—
history* (required)

Saved values, newest first. The first one is what's saved now.

FieldVersion[]—
value

What the field holds right now, if it may differ from the saved value (an unsaved edit).

string—
onRevert* (required)

Puts one value back. Return a promise to show a pending state; a rejection keeps things as they were.

(value: string) => void | Promise<void>—
format

Formats a value for display, e.g. `(v) => "₹" + v`.

(value: string) => string(v) => v
you

The current user's name as it appears in `by`, so your own edits don't get flagged.

string—
recentFor

A change by someone else is flagged on the trigger for this long, in ms.

number3 * DAY
defaultOpen

Open the history panel on first render.

booleanfalse
limit

How many older values the list shows.

number4
wasText

Templates: `{previous}`, `{by}` and `{when}` are filled in.

string"Was {previous} until {by} changed it {when}."
changedText

Trigger text while a recent change is flagged. `{when}` is filled in.

string"Changed {when}"
historyLabel

Accessible label for the history trigger.

string"History"
revertLabel

Text for the revert button.

string"Revert to {value}"
restoreLabel

Text for restoring an older value.

string"Restore"
restoreAriaLabel

Screen reader name of each Restore button. `{value}` is filled in. Defaults to `restoreLabel` plus the value.

string`${restoreLabel} {value}`
replacesText

Shown above revert when the field holds an unsaved edit. `{value}` is filled in.

string"Replaces your unsaved {value}."
revertedText

Shown after a revert. `{value}` is filled in.

string"Reverted to {value}."
undoLabel

Text for the Undo button.

string"Undo"
emptyText

Shown when there is no history.

string"empty"
locale

Language for "when" ("vor 2 Tagen"). Unset keeps the built-in English wording.

string—
formatWhen

Full control over "when", e.g. your app's own relative-time helper. Wins over `locale`.

(at: Date | number | string, now: number) => string—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Field History accessible?

  • Pass htmlFor so the label is a real <label> for the field
  • The trigger has aria-expanded, aria-controls and an aria-label that says when it changed
  • Animations respect prefers-reduced-motion

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

  • History comes from your props; it doesn't track changes itself
  • Reverting runs your onRevert

What expensive mistakes does Field History stop?

Overwrote teammate's change unknowingly

Also known as

field history · audit log · change history · revert · who changed · activity · collaboration · price change

Field type

What dependencies does Field History require?

Field History facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameField History
Registry identifier@bollard/field-history
Install commandnpx shadcn@latest add @bollard/field-history
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Field History

What form validation mistake does Field History catch?

Field History prevents overwrote teammate's change unknowingly. Flags a field someone else just changed and shows its previous value with a one-tap revert, so a teammate's change isn't overwritten unknowingly. Catches: Recent changes by someone else (within recentFor), The previous value and who changed it, Reverts that would also replace your unsaved edit, Regret after a revert, with Undo. Limitation: validate field-history schemas on backend.

How do I install field-history with shadcn?

Run `npx shadcn@latest add @bollard/field-history`. Sources added: registry/default/field-history/field-history.tsx. Package requirements: lucide-react.

What props customize Field History?

Field History accepts `label`, `htmlFor`, `children`, `history`, `value`. Configures field history, audit log, change history behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of field-history?

History comes from your props; it doesn't track changes itself. Reverting runs your onRevert Server requirement: backend verification for field-history.

How does Field History meet accessibility guidelines?

Pass htmlFor so the label is a real <label> for the field. The trigger has aria-expanded, aria-controls and an aria-label that says when it changed. Animations respect prefers-reduced-motion. Minimizes errors: someone changed the price, who changed this field.

Which components pair with Field History?