Revision Banner

Makes an old revision unmistakable and read-only, and confirms what "Restore this version" replaces before it does.

StopsEdited an old version by mistake

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/revision-banner.json

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

What it catches

  • Viewing an old revision, said up front with how far behind it is
  • Edit attempts on the old version, explained instead of silently ignored
  • Restore impact: which version it replaces and words changed
  • Restore errors, with the latest kept

Props

RevisionBanner props
PropTypeDefault
revision* (required)

The old revision on screen.

RevisionInfo—
latest* (required)

The current, latest revision.

RevisionInfo—
behind

How many revisions newer than this one exist.

number—
revisionText

Plain text of both revisions, to count the words a restore would change.

string—
latestText

Text describing the latest version.

string—
onGoToLatest* (required)

Open the latest revision.

() => void—
onRestore* (required)

Make this revision the latest. Return a promise to show progress; a rejection shows `errorText`.

() => void | Promise<void>—
children* (required)

The old revision's content. Edits inside it are blocked.

React.ReactNode—
formatDate

Formats revision dates.

(date: Date) => stringdefaultFormatDate
message

Templates: `{label}`, `{author}`, `{date}`, `{behind}`, `{latest}`, `{added}`, `{removed}` are filled in.

string"You're viewing {label} from {date}{author}. This isn't t…
behindText

Says how many versions behind this one is.

string"{behind} newer {versions} saved since"
editBlockedText

Shown when someone tries to edit the old version.

string"Old versions are read-only. Go to the latest to edit, or…
confirmText

Restore confirmation question.

string"Restore {label}? It replaces {latest}{latestAuthor}, sav…
impactText

Says how many words the restore changes.

string"{removed} removed, {added} brought back."
keptText

Says the latest version is kept in history.

string"{latest} stays in history, so you can undo this."
goToLatestLabel

Label of the go-to-latest button.

string"Go to latest"
restoreLabel

Label of the restore button.

string"Restore this version"
confirmRestoreLabel

Label of the confirm-restore button.

string"Replace with {label}"
cancelLabel

Label of the Cancel button.

string"Cancel"
errorText

Shown when onRestore rejects.

string"Couldn't restore. Nothing was changed."

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

Accessibility

  • Banner is a region with an aria-label naming the version
  • Content frame is role=group with aria-readonly and an aria-label
  • Restore confirmation focuses Cancel first; Escape closes it
  • Blocked-edit note in a polite live region; errors use role=alert

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

Limitations

  • Read-only framing is visual and ARIA; it does not disable editors you render inside
  • Word-change count comes from what you pass

What it stops

Edited an old version by mistake

Also known as

version history · revision · restore version · document history · read only · docs · wiki · cms

Field type

Dependencies

Pairs well with