Message branches
ProPage through versions of a reply (after a retry or an edited question): "‹ 2 / 3 ›". Lives in the message actions row.
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
"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>
| Prop | Type | Default | Description |
|---|---|---|---|
| indexrequired | number | — | The version shown, from 0. |
| countrequired | number | — | 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. |
| className | string | 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.
| Key | English |
|---|---|
| versions | Versions of this reply |
| previous | Previous version |
| next | Next version |
| position | {index} / {count} |