Branch

Navigate alternate reply branches when regenerating or editing a turn.

Branch cycles through alternate reply versions after regenerate or edit. The selector hides itself when only one branch exists.

Start with the changelog, then run smoke tests before cutover.

Installation

pnpm dlx cubix@latest add branch

Usage

Import
import {
  Branch,
  BranchContent,
  BranchNext,
  BranchPage,
  BranchPrevious,
  BranchSelector,
} from "@/components/cubix/branch"
Example
<Branch defaultBranch={0}>
  <BranchContent>
    <Bubble>...</Bubble>
    <Bubble>...</Bubble>
  </BranchContent>
  <BranchSelector>
    <BranchPrevious />
    <BranchPage />
    <BranchNext />
  </BranchSelector>
</Branch>

Composition

 
Branch
├── BranchContent
   └── (each child = one branch)
└── BranchSelector
    ├── BranchPrevious
    ├── BranchPage
    └── BranchNext

Features

  • Compact prev / page / next selector
  • Circular navigation across reply versions
  • Controlled and uncontrolled modes
  • RTL-safe chevrons and numeric order

Single branch

Only one reply version exists, so the selector stays hidden.

Forced selector

Force the selector even with a single branch for layout testing.
1/1

Controlled

Ship behind a flag, migrate first, and keep rollback ready for an hour.

Many branches

Version C focuses on user-facing risk and communication.

Custom page label

Start with the changelog, then run smoke tests before cutover.

End aligned

Start with the changelog, then run smoke tests before cutover.

In a message

Start with the changelog, then run smoke tests before cutover.

RTL

To enable RTL support, see the Direction guide. Chevrons flip with dir="rtl" and IRANSans XV follows lang="fa".

اول changelog را بخوان، بعد قبل از cutover تست دود بزن.

API Reference

Branch

PropTypeDefaultDescription
branchnumber-Controlled branch index. Pair with onBranchChange.
defaultBranchnumber0Initial branch index when uncontrolled.
onBranchChange(branchIndex: number) => void-Called when the active branch changes.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

BranchContent

PropTypeDefaultDescription
childrenReact.ReactNode-One child per reply branch. Only the active branch is shown.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

BranchSelector

PropTypeDefaultDescription
forcebooleanfalseAlways render the selector, even when there is only one branch.
aria-labelstring"Reply branches"Accessible name for the selector group.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

BranchPrevious / BranchNext

PropTypeDefaultDescription
childrenReact.ReactNode-Optional custom icon or label. Defaults to a chevron.
aria-labelstring"Previous branch" / "Next branch"Accessible name for the previous or next control.

BranchPage

PropTypeDefaultDescription
childrenReact.ReactNode-Optional custom label. Defaults to "1 / 3" style paging.
classNamestring-Additional Tailwind classes merged with the component styles (last one wins).

useBranch

PropTypeDefaultDescription
currentBranchnumber-Active branch index (0-based).
totalBranchesnumber-Number of children registered by BranchContent.
goToPrevious() => void-Cycle to the previous branch, wrapping at the start.
goToNext() => void-Cycle to the next branch, wrapping at the end.