Skip to content
Component installs need the registry setup
VegaStack Design

Version List

A document's version history — time, author, name, kind badges (Current, Restored, Unsaved copy), a Named only switch and Load more — as a keyboard listbox.

Status
stable
Since
0.23.74
Accessibility pattern
listbox with one tab stop, labelled switch

Last updated

Version history

CurrentARAsha Rao
Unsaved copyBLBo Lindqvist
Before the inspectionARAsha Rao
RestoredARAsha Rao
BLBo LindqvistAdded the wiring section

Install

Add Version List from the VegaStack registry. The CLI verifies the item's integrity hash before writing it.

pnpm dlx shadcn@latest add @vegastack/version-list

The same command installs the registry items it composes: @vegastack/badge, @vegastack/button, @vegastack/person-avatar, @vegastack/relative-time, @vegastack/skeleton, @vegastack/switch, @vegastack/use-list-nav.

Usage

import { VersionList } from "@/components/ui/version-list";

<VersionList
  versions={versions}
  currentId={versions[0]?.id}
  selectedId={selected}
  onSelect={setSelected}
  namedOnly={namedOnly}
  onNamedOnlyChange={setNamedOnly}
  loadMore={{ hasMore, onLoadMore: fetchMore, loading: fetching }}
/>;

Each row shows when the version's text was saved and who wrote it; a named version leads with its name. A restore is badged "Restored", a save that lost a race and was kept is "Unsaved copy", and currentId is "Current". Pair it with DiffView for the selected version.

Version history

CurrentARAsha Rao
Unsaved copyBLBo Lindqvist
Before the inspectionARAsha Rao
RestoredARAsha Rao
BLBo LindqvistAdded the wiring section

Anatomy

VersionList — data-slot="version-list" | "version-list-empty" | "version-list-header" | "version-list-item" | "version-list-items" | "version-list-skeleton"

Examples

Loading and empty

loading shows a skeleton; with no versions the list says "No versions yet" (emptyState).

Version history

Version history

No versions yet

API Reference

PropTypeDefaultDescription
versions*readonly VersionItem[]—The versions, newest first.
classNamestring—Classes for the list.
currentIdstringnullThe version that is the document's current text: a "Current" badge.
emptyStateReact.ReactNode"No versions yet"Shown when there are no versions.
loadingbooleanfalseShow the skeleton instead of the list.
loadMore{ hasMore: boolean; onLoadMore: () => void; loading?: boolean; }—More versions exist: a "Load more" footer (keyset lists have no totals).
namedOnlybooleanfalseShow named versions only (controlled).
nownumber—Pin the relative times' clock (docs, tests).
onNamedOnlyChange((namedOnly: boolean) => void)—Called from the header's "Named only" switch; the switch shows when set.
onSelect((id: string) => void)—Called when a version is picked — by click, or as the arrow keys move.
selectedIdstringnullThe selected version (shown in the diff beside the list).

Data attributes and CSS variables on VersionList

AttributeValues
data-kindmirrors a prop or state value
data-selected""
data-slot"version-list" | "version-list-empty" | "version-list-header" | "version-list-item" | "version-list-items" | "version-list-skeleton"
PropTypeDefaultDescription
at*string | number | Date—When that text was last saved.
author*Person—Who wrote the text this version holds.
id*string—Stable id.
kind*"auto" | "conflict" | "named" | "restore"—How it came to be: auto (an editing session), named, restore (a restore of an older version — "Restored") or conflict (a save that lost a race, kept — "Unsaved copy").
namestring—A name the author gave it; named versions lead with it.
summarystring—A muted second line — "12 words added".

Accessibility

  • The rows are a listbox labelled "Version history", each an option with aria-selected; the list is one tab stop and the selection follows the arrow keys.
  • "Named only" is a switch labelled by its text.
KeyAction
↑ / ↓Select the previous / next version
Home / EndSelect the newest / oldest shown
TabLeave the list
ContractStates tested
Behaviourloading, empty, selected, named-only, loading-more
Accessibilitylabeled, browser-accessibility-test, keyboard
Visualdefault, selected

Do / Don't

Do
Keep the list newest first and page it with loadMore — keyset lists have no totals.
Don't
Show a version count or page numbers, or make restoring a version a row click.

On this page