BranchTree
neon-ui/branch-treeFreeComponent
A drawn branch graph: nodes colored by compute state, curved edges to each parent, default and selected marked.
Install it
npx shadcn@latest add https://ui.neon.com/r/branch-tree.jsonSource
1"use client";23import { GitBranchIcon, SquareLock01Icon } from "@hugeicons/core-free-icons";4import { HugeiconsIcon } from "@hugeicons/react";5import { useState } from "react";6import type { ComponentProps } from "react";78import { cn } from "@/lib/utils";910/** Compute lifecycle, mirrored from ComputeStatus. Drives the node color. */11export type ComputeState = "active" | "idle" | "scaling" | "suspended";1213export interface Branch {14 id: string;15 name: string;16 /** The project's default branch: its node wears a primary ring. */17 default?: boolean;18 /** A protected branch: shows a lock. */19 protected?: boolean;20 /** The parent branch's id; the edge is drawn from it. */21 parent?: string;22 /** Compute state, painted onto the node dot. */23 state?: ComputeState;24 /** ISO timestamp of the branch's last update, shown as relative time. */25 updatedAt?: string;26}2728interface TreeNode {29 branch: Branch;30 depth: number;31 row: number;32}3334/* ─────────────────────────────────────────────────────────35 * GEOMETRY36 *37 * The graph is a real node-link drawing, not indent guides.38 * Rows stack at a fixed height; a branch sits in the lane of39 * its depth. Each child's edge leaves its parent's lane,40 * runs down, and curves (a fixed-radius quarter turn) into41 * the child's node. Node color is the compute state; the42 * default branch and the selected branch wear a ring.43 * ───────────────────────────────────────────────────────── */44const ROW_H = 46;45const LANE_W = 22;46const PAD_X = 18;47const DOT_R = 3.5;48const CORNER = 12;4950const laneX = (depth: number) => PAD_X + depth * LANE_W;51const rowY = (row: number) => row * ROW_H + ROW_H / 2;5253/** Staggered entrance: edges draw, nodes pop, rows fade, top to bottom. */54const STAGGER = 0.06;55const DRAW = 0.45;56const POP = 0.32;5758const BRANCH_TREE_STYLES = `59@keyframes neon-bt-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }60@keyframes neon-bt-pop { from { opacity: 0; transform: scale(0.2); } to { opacity: 1; transform: scale(1); } }61@keyframes neon-bt-row { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }62@media (prefers-reduced-motion: reduce) {63 [data-slot="branch-tree"] * { animation: none !important; }64}65`;6667// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from neon-ui
All 77 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ActivityFeedactivity-feed | neon-ui | Components | Free | 2 deps | |
| AgentChatagent-chat | neon-ui | Components | Free | 6 deps | |
| AnimatedWashanimated-wash | neon-ui | Components | Free | no deps · 2 files | |
| ApiKeyListapi-key-list | neon-ui | Components | Free | 2 deps | |
| AppCardapp-card | neon-ui | Components | Free | 2 deps | |
| AppCreatorapp-creator | neon-ui | Components | Free | 2 deps | |
| AuthFormauth-form | neon-ui | Components | Free | no deps | |
| AutoscaleChartautoscale-chart | neon-ui | Components | Free | 1 dep |
