Mark Yo

Branch Navigator

Component

About

A version switcher for regenerated or edited chat messages that animates between versions and shows a "‹ 2 / 3 ›" counter control with arrow/Home/End keyboard navigation.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Branch Navigator to your project and fits it to your theme.

Code

How Branch Navigator is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import {
  Branches,
  BranchContent,
  BranchNavigator,
} from "@/components/ui/branch-navigator";
import * as React from "react";

const VERSIONS = [
  "Here's a concise summary of the quarterly report: revenue is up 8% year over year.",
  "Here's a more detailed summary of the quarterly report, including key metrics, regional breakdowns and notable trends across the last four quarters.",
  "Here's a shorter, bullet-pointed summary of the quarterly report for quick scanning:\n- Revenue +8% YoY\n- Costs flat\n- Margin improved",
];

export default function BranchNavigatorDemo() {
  const [index, setIndex] = React.useState(0);

  return (
    <div className="flex w-full max-w-md flex-col gap-3 rounded-lg border bg-card p-4">
      <Branches count={VERSIONS.length} index={index} onIndexChange={setIndex}>
        <BranchContent>
          {VERSIONS.map((text, i) => (
            <p key={i} className="whitespace-pre-line text-sm text-foreground">
              {text}
            </p>
          ))}
        </BranchContent>
        <div className="mt-2 flex justify-end">
          <BranchNavigator label="response" />
        </div>
      </Branches>
    </div>
  );
}

Dependencies

More by Mark Yo

View all
  • Loader

    Loader

    72
  • Pricing Table

    Pricing Table

    29
  • Bento Grid

    Bento Grid

    18
  • Expandable Tabs

    Expandable Tabs

    18
  • Wallet Card

    Wallet Card

    15
  • Image Gallery

    Image Gallery

    11
  • CTA Section

    CTA Section

    10
  • Approval Queue

    Approval Queue

    9