Anchor Port

Port marker for object inputs, outputs, and bidirectional links on the canvas. Install Anchor Port from the VLLNT UI registry with the shadcn CLI.

Report a bug

What it is and when to use

Anchor Port is a small presentational marker for the connection points on a canvas node. It renders a colored dot that signals whether a port is an input, an output, or bidirectional, using a distinct tone for each. Side props place it on the top, right, bottom, or left edge, and state props show it as idle, active, or blocked. It carries an image role and a descriptive label, so screen readers announce each port. Reach for it when wiring node-based editors or flow diagrams.

Utility

Port marker for object inputs, outputs, and bidirectional links on the canvas. Part of the utility family in VLLNT UI, it ships as a machine-readable registry entry — copy the source directly into your app with the shadcn CLI and own it, no runtime dependency on a component library.

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Installation

Add Anchor Port to your project with the shadcn CLI. The source lands in your codebase, ready to adapt:

pnpm dlx shadcn@latest add https://ui.vllnt.com/r/anchor-port.json

Source

import { cn } from "../../lib/utils"; export type AnchorPortProps = React.ComponentPropsWithoutRef<"span"> & { side?: "bottom" | "left" | "right" | "top"; state?: "active" | "blocked" | "idle"; tone?: "bidirectional" | "input" | "output"; }; const toneClasses: Record<NonNullable<AnchorPortProps["tone"]>, string> = { bidirectional: "border-violet-500/40 bg-violet-500/15 text-violet-700 dark:text-violet-300", input: "border-sky-500/40 bg-sky-500/15 text-sky-700 dark:text-sky-300", output: "border-emerald-500/40 bg-emerald-500/15 text-emerald-700 dark:text-emerald-300", }; const stateClasses: Record<NonNullable<AnchorPortProps["state"]>, string> = { active: "scale-100 opacity-100", blocked: "opacity-60 saturate-50", idle: "opacity-80", }; const sideClasses: Record<NonNullable<AnchorPortProps["side"]>, string> = { bottom: "self-end", left: "self-start", right: "self-end", top: "self-start", }; const AnchorPort = ({ className, ref, side = "right", state = "idle", tone = "bidirectional", ...props }: AnchorPortProps & { ref?: React.Ref<HTMLSpanElement> }) => ( <span aria-label={props["aria-label"] ?? `${tone} ${side} port ${state}`} className={cn( "inline-flex size-7 items-center justify-center rounded-full border shadow-sm", toneClasses[tone], stateClasses[state], sideClasses[side], className, )} data-side={side} data-state={state} data-tone={tone} ref={ref} role="img" {...props} > <span className="size-2.5 rounded-full bg-current" /> </span> ); AnchorPort.displayName = "AnchorPort"; export { AnchorPort };

Stories

Explore every variant and state in the interactive Storybook:

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Dependencies

  • @vllnt/ui@^0.3.0

FAQ

What is Anchor Port?
Anchor Port is a React component that renders a small color-coded marker for the connection points on a canvas node, signaling whether a port is an input, an output, or a bidirectional link. It is pure presentation — the host owns wiring and drag logic.
How do I add Anchor Port?
Run `pnpm dlx shadcn@latest add https://ui.vllnt.com/r/anchor-port.json` to install it into your React project via the shadcn CLI, then render the AnchorPort element on a node edge.
What variants does Anchor Port support?
Anchor Port has three tones — input, output, and bidirectional — each with its own color, four side placements (top, right, bottom, left), and three states: idle, active, and blocked. It renders with an image role and a descriptive aria-label by default.