Branch Target

Branch Target is a copy-paste React component that stops feature branch merged into wrong base before the user submits. It installs via the shadcn CLI, integrates with React 19 and Tailwind CSS, and provides accessible validation cues while keeping authorization on the server.

pnpm dlx shadcn@latest add @bollard/branch-target
Version 0.1.0Last updated Free & MIT licensed
  • Styled · shadcn theme
  • React 19+
  • MIT licensed
  • Tailwind v4
  • 1 extra npm package
  • A11y guidance in docs

StopsFeature branch merged into wrong base

Was this component page useful?

How do I install Branch Target?

pnpm dlx shadcn@latest add @bollard/branch-target

The files land in your project. They're yours to edit.

How do I use Branch Target in React?

branch-target-usage.tsx
import { BranchTarget } from "@/components/ui/branch-target"

<BranchTarget
  head="feature/otp-login"
  branches={branches}
  defaultValue="main"
  forkedFrom="develop"
  headCommits={3}
  onIssuesChange={(_, { blocking }) => setBlocked(blocking)}
/>

What input mistakes does Branch Target catch?

  • A target the rules don't allow for this head, with a one-tap switch to an allowed one
  • Commits the merge would bring in that are not the head's own (wrong fork point)
  • A head that is behind its target
  • Targeting the head branch itself

What props does Branch Target accept?

BranchTarget props
PropTypeDefault
head* (required)

The branch being merged or deployed.

string—
branches* (required)

Possible targets with their ahead/behind counts.

BranchInfo[]—
value

Selected target (controlled).

string—
defaultValue

Selected target when uncontrolled.

string—
onValueChange

Called with the newly chosen target branch.

(target: string) => void—
rules

Allowed head → target pairs. Defaults to git-flow.

TargetRule[]DEFAULT_TARGET_RULES
forkedFrom

The branch the head was cut from, if known. Enables the "commits that aren't yours" check.

string—
headCommits

Commits that are the head's own work.

number—
mode

Picks the copy: "merge" for pull requests, "deploy" for environments.

"merge" | "deploy""merge"
onUpdate

Brings the head up to date with the target. May return a promise; shows a pending state.

(target: string) => void | Promise<void>—
label

Visible label for the target picker.

stringmode === "merge" ? "Merge into" : "Deploy to"
summaryText

Readback under the picker. `{head}`, `{target}`, `{count}` and `{commits}` are filled in.

stringmode === "merge" ? "Merges {commits} from {head} into {ta…
messages

Warning text per issue. `{head}`, `{target}`, `{count}`, `{commits}` ("3 commits"), `{allowed}`, `{forkedFrom}`, `{verb}` are filled in.

Partial<Record<TargetIssueKind, string>>—
switchLabel

Label of the one-tap fix. `{suggestion}` is filled in.

string"Switch to {suggestion}"
updateLabel

`{head}` and `{target}` are filled in.

stringmode === "merge" ? "Update branch" : "Update {head}"
updatingLabel

Update button text while onUpdate runs.

string"Updating…"
protectedLabel

Badge text for protected branches.

string"protected"
behindLabel

How far the head is behind a target, in the picker. `{head}`, `{count}` and `{commits}` are filled in.

stringmode === "merge" ? "{head} is {commits} behind" : "{commi…
onIssuesChange

Called whenever the issues for the selected target change, so a form can block its submit on `blocking`.

(issues: TargetIssue[], state: { blocking: boolean; target: string }) => void—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

How is Branch Target accessible?

  • Native <select> with a <label>, aria-invalid when blocked and aria-describedby to its hint
  • The hint is aria-live="polite"
  • Update uses aria-disabled while updating

Only what the source does. Test with your own screen reader and content before shipping.

What are the limitations and server boundaries?

This is a UX guard rail. Enforce on the server: Enforce branch protection and allowed merge targets in your Git host; this picker is a guide, not a protection rule.

  • Uses the branch rules, commit lists and fork point you pass; it does not query Git
  • Wildcard rules are simple * patterns; the first matching rule wins

What expensive mistakes does Branch Target stop?

Feature branch merged into wrong base

Also known as

base branch · pull request · merge request · git flow · deploy target · main · develop · update branch

Field type

What dependencies does Branch Target require?

Branch Target facts & technical specifications

Technical specifications, licensing, and limitations
PropertySpecification
Component nameBranch Target
Registry identifier@bollard/branch-target
Install commandnpx shadcn@latest add @bollard/branch-target
LicenseMIT License (free, commercial-friendly)
Price$0 (100% Free and Open Source)
Version0.1.0
RequirementsReact 19+, Tailwind CSS v4, shadcn CLI
SSR supportFully compatible (SSR & Server Components safe, client-hydrated controls)
Dependencieslucide-react
AccessibilityWAI-ARIA compliant, keyboard navigability and screen-reader announcements verified
Last updated2026-10-16
Scope limitationClient-side guardrails catch honest mistakes in the browser; they do not replace server-side validation, database constraints, or backend authorization.

Frequently asked questions about Branch Target

How does Branch Target protect destructive mutations?

Branch Target prevents feature branch merged into wrong base. Enforces deliberate friction against A target the rules don't allow for this head, with a one-tap switch to an allowed one, Commits the merge would bring in that are not the head's own (wrong fork point), A head that is behind its target, Targeting the head branch itself. Limitation: authorize branch-target mutations on the server.

How do I install branch-target with shadcn?

Run `npx shadcn@latest add @bollard/branch-target`. Sources added: registry/default/branch-target/branch-target.tsx. Package requirements: lucide-react.

What props customize Branch Target?

Branch Target accepts `head`, `branches`, `value`, `defaultValue`, `onValueChange`. Configures base branch, pull request, merge request behavior. Limitation: invalid prop values fallback to safe default options.

What are the limits of branch-target?

Uses the branch rules, commit lists and fork point you pass; it does not query Git. Wildcard rules are simple * patterns; the first matching rule wins Server requirement: Enforce branch protection and allowed merge targets in your Git host; this picker is a guide, not a protection rule.

How does Branch Target meet accessibility guidelines?

Native <select> with a <label>, aria-invalid when blocked and aria-describedby to its hint. The hint is aria-live="polite". Update uses aria-disabled while updating. Minimizes errors: merged into main instead of develop, pr opened against wrong branch.

Which components pair with Branch Target?