Skip to content
ConversationBranch navigatorMenu

Branch navigator

Moves between the versions of an edited message or a regenerated reply: previous, 2 / 3, next.

Move between regenerated replies.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/branch-navigator.json

Usage

tsx
import { BranchNavigator } from "@/components/ui/chatcn/branch-navigator"

<BranchNavigator count={versions.length} index={index} onIndexChange={setIndex} />

Props

PropTypeNotes
countnumberNumber of versions. Renders nothing below 2
index, defaultIndex, onIndexChangenumber0-based. Defaults to the newest
pendingbooleanA new version is generating: shows a spinner by the count
nounstringUsed in labels. Defaults to version

Keyboard

KeyAction
←, →Previous and next version while focused (mirrored in right-to-left)
Home, EndFirst and last version

Accessibility

  • The group is labeled Version 2 of 3, and the buttons Previous version and Next version.
  • The ends use aria-disabled instead of disabled, so focus stays on a button that reaches the end.
  • The count uses tabular figures, so the control never changes width.

Motion

The navigator itself does not animate. Crossfade the content below it if you like, as the example does, over 150 ms.