Message branches

Pro

Page through versions of a reply (after a retry or an edited question): "‹ 2 / 3 ›". Lives in the message actions row.

Markdown

Preview

Install

With the Candor CLI

First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/message-branches

Brings in: locale, utils · npm: lucide-react@^1.67.0

Usage

TSX · The example above
"use client"

import * as React from "react"
import { MessageBranches } from "@/components/message-branches"

const versions = [
  "The migration adds a nullable region column to orders, so it’s safe to run on Production.",
  "The migration adds a nullable region column to orders. It takes a brief lock, so run it outside peak hours.",
  "The migration adds region to orders. Backfill it on Staging first; the table has 1.2M rows.",
]

export default function Example() {
  const [index, setIndex] = React.useState(versions.length - 1)
  return (
    <div className="flex max-w-lg flex-col gap-2">
      <p className="text-sm">{versions[index]}</p>
      <MessageBranches index={index} count={versions.length} onChange={setIndex} />
    </div>
  )
}

<MessageBranches>

PropTypeDefaultDescription
indexrequirednumber—The version shown, from 0.
countrequirednumber—How many versions there are. Renders nothing below 2.
onChangerequired(index: number) => void—Called with the index of the version to show when a person pages back or forward.
classNamestring | undefined—Extra classes for the outer element.

Strings

The fixed words, in English by default. Change any of them under messageBranches in <LocaleProvider strings={{ … }}>; the table is exported as messageBranchesStrings.

KeyEnglish
versionsVersions of this reply
previousPrevious version
nextNext version
position{index} / {count}