Skip to content
Browse components

CommitGraph

Commits beside the branch lanes they sit on. Pick a branch to see only its commits.

History

relay/web

Installation

Run this in a project that has a components.json. It adds one file, components/tenor-ui/commit-graph.tsx, and no packages.

pnpm dlx shadcn@latest add https://tenor.design/r/commit-graph.json

No components.json? Fetch the file. It works in any React project.

curl --create-dirs -o src/components/tenor-ui/commit-graph.tsx https://tenor.design/r/commit-graph.tsx

Usage

Every prop is optional. With none, it renders the content you see above.

<CommitGraph />
import { CommitGraph } from "@/components/tenor-ui/commit-graph"; export function RepositoryHistory() { return ( <CommitGraph repository="acme/storefront" branches={[ { name: "main" }, { name: "feat/checkout", from: "41c07ae", into: "9d2f6b3", earlier: [{ hash: "70be5d1", message: "Sketch the checkout form", author: "Lena", time: "6 days ago" }], }, ]} commits={[ { hash: "9d2f6b3", message: "Merge branch 'feat/checkout' into main", author: "Omar", time: "1 day ago", branch: "main", merge: true }, { hash: "e15a9c0", message: "Validate the card number", author: "Lena", time: "2 days ago", branch: "feat/checkout" }, { hash: "b3740fd", message: "Add the order summary", author: "Lena", time: "3 days ago", branch: "feat/checkout" }, { hash: "41c07ae", message: "Upgrade the payments client", author: "Omar", time: "4 days ago", branch: "main" }, ]} onBranchChange={(branch) => console.log("Showing", branch)} onFetch={() => fetch("/api/history/refresh", { method: "POST" })} /> ); }

Props

PropTypeDefaultWhat it does
theme"dark" | "light""dark"Dark or light palette.
commitsreadonly CommitGraphCommit[]commitGraphCommitsThe history, newest first. A commit on a branch that is not in branches is left out.
branchesreadonly CommitGraphBranch[]commitGraphBranchesBranches in lane order, left to right. The first is the trunk: its view shows every commit. With none, nothing renders.
branchstringNoneName of the selected branch when it is controlled. Pair with onBranchChange.
defaultBranchstringNoneName of the branch selected at first when it is not controlled. Left out, the trunk.
onBranchChange(branch: string) => voidNoneCalled with a branch's name when it is picked or the selector moves on to it.
repositorystring"relay/web"Repository name beside the heading.
intervalnumber6000Milliseconds on each branch before the selector moves to the next, not counting time it is open, hovered or focused. 0 keeps the selected branch.
onFetch() => void | Promise<unknown>NoneCalled when the button is pressed. Return a promise and the icon spins until it settles.
labelsPartial<CommitGraphLabels>commitGraphLabelsReplaces the card's wording, key by key.

It also takes every attribute of its root element, such as className and style.

Theming

Set any of these CSS variables on the component or on an ancestor. Each falls back to the look shown here.

  • --tui-surface
  • --tui-stroke
  • --tui-text
  • --tui-muted
  • --tui-control
  • --tui-control-hover
  • --tui-menu
  • --tui-window
  • --tui-row-hover
  • --tui-message
  • --tui-dim
  • --tui-subtle
  • --tui-lane-1
  • --tui-lane-2
  • --tui-lane-3
  • --tui-lane-4
  • --tui-lane-5
  • --tui-font-sans
  • --tui-font-mono