Branch Navigator

Version switcher for regenerated or edited messages: `Branches` shares a controlled or uncontrolled index, `BranchContent` cross-fades and slides the active version in from the direction you navigated, and `BranchNavigator` renders a "‹ 2 / 3 ›" control with a rolling counter, arrow/Home/End keys and live announcements, usable standalone too.

Preview

Branch Navigator preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/branch-navigator
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

Branches

count
number

Number of versions (match the `BranchContent` children).

—
index?
number
—
defaultIndex?
number
0
onIndexChange?
((index: number) => void)
—
className?
string
—

BranchContent

children
ReactNode

One child per version; only the active one renders.

—
className?
string
—

BranchNavigator

count?
number

Omit inside `Branches`; required standalone.

—
index?
number
—
defaultIndex?
number
—
onIndexChange?
((index: number) => void)
—
label?
string

Noun used in labels, e.g. "response" → "Previous response".

—
hideWhenSingle?
boolean

Hide the control when there is only one version. Default true.

—
className?
string
—

Updated