Pipecat UI
Graph

Node Connector

Ports on a node's left and right edges, with or without labels — circles or diamonds, outlined, dashed or solid, in the node's tone or their own.

View in Storybook

Installation

pnpm dlx shadcn@latest add @pipecat/graph-node-connector

Also installs @pipecat/graph-tone, @pipecat/graph-node as registry dependencies.

This installs Node and Tones too.

Usage

import {
  GraphNode,
  NodeCard,
  NodeContent,
} from "@/components/pipecat/graph/node";
import {
  NodeConnector,
  NodeConnectorLabel,
  NodeConnectorPort,
  NodeConnectorsLeft,
  NodeConnectorsRight,
} from "@/components/pipecat/graph/node-connector";

<GraphNode>
  <NodeCard>
    <NodeConnectorsLeft>
      <NodeConnector>
        <NodeConnectorPort />
      </NodeConnector>
    </NodeConnectorsLeft>
    <NodeContent>Holds the slot the caller chose.</NodeContent>
    <NodeConnectorsRight>
      <NodeConnector>
        <NodeConnectorPort />
        <NodeConnectorLabel>Booked</NodeConnectorLabel>
      </NodeConnector>
      <NodeConnector>
        <NodeConnectorPort />
        <NodeConnectorLabel>No slots</NodeConnectorLabel>
      </NodeConnector>
    </NodeConnectorsRight>
  </NodeCard>
</GraphNode>;

Connectors are markup and CSS, like the node: a port marks where a wire ends, and drawing the wire is the canvas's job.

Parts

PartWhat it is
NodeConnectorsLeft, NodeConnectorsRightA column of connectors on one edge of a node, level with its content.
NodeConnectorOne row: a port, and a label if it needs one.
NodeConnectorPortWhere a wire ends. It sits centred on the card's edge.
NodeConnectorLabelThe connector's name. It truncates rather than widen the node.

Both sides take the same connectors. A label sits the node's own inline padding from its edge, in line with the header and content. An area is as wide as its labels, so one with ports alone takes no room from the content, and the node grows to fit however many rows you give it. Rows are centred in the area; pass justify-start or justify-end to move them.

An area can go inside NodeCard or beside it. Put it beside the card when the card animates and the ports should hold still.

Ports

PropValuesDoes
shapecircle, diamondA diamond marks a link into or out of another graph.
variantoutline, dashed, solidThe ring alone, a dashed ring, or filled with the tone.

A port shows a halo in its tone when the pointer is over it.

Tone and state

A connector takes its node's tone. Give one its own with tone, and its port and label follow:

<NodeConnector tone="coral">
  <NodeConnectorPort />
  <NodeConnectorLabel>Declined</NodeConnectorLabel>
</NodeConnector>

active marks the connector in use: the port fills and the label is tinted. States that depend on a wire being dragged belong to the canvas; set a data- attribute on the port and style from it.

On a canvas

On a Graph, render a port as React Flow's Handle and wires attach to it. The port keeps its place on the node's edge:

import { Handle, Position } from "@xyflow/react";

<NodeConnector>
  <NodeConnectorPort
    render={<Handle type="source" position={Position.Right} id="booked" />}
  />
  <NodeConnectorLabel>Booked</NodeConnectorLabel>
</NodeConnector>;

A wire ends at the port's outer edge. Give a node with more than one output an id on each handle.

Styling

Each part takes className and Base UI's render prop, and carries a data-slot (node-connectors, node-connector, node-connector-port, node-connector-label). An area also carries data-side, a connector data-active and data-tone, and a port data-shape and data-variant.

Sizes live in variables on each area. They default from the node's type, so connectors follow the node's size; set them on the area to change them.

VariableSets
--node-connector-heightThe height of a row.
--node-connector-portThe diameter of a port.
--node-connector-textLabel text.
--node-connector-max-widthHow wide an area may grow before its labels truncate.
<NodeConnectorsRight className="[--node-connector-height:--spacing(7)] [--node-connector-port:--spacing(4)]">
  …
</NodeConnectorsRight>

Key props

PropOnTypeDescription
toneNodeConnectora palette tone, or your ownThe connector's own tone. Defaults to the node's.
activeNodeConnectorbooleanThe connector in use.
shapeNodeConnectorPort"circle" | "diamond"Default circle.
variantNodeConnectorPort"outline" | "dashed" | "solid"Default outline.
renderEvery partReactElement | functionRender the part as another element.

On this page