Pipecat UI
Graph

Node

The parts of a graph node as plain markup — a box, a card, header, content and footer — in four sizes, fixed or fluid, with room on either side for connectors and a status for live playback.

View in Storybook

Installation

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

Also installs @pipecat/graph-tone as registry dependency.

This installs Tones too, the palette a node takes its tone from. It doesn't need a Graph: a node is plain markup and works anywhere.

Usage

import {
  GraphNode,
  NodeCard,
  NodeContent,
  NodeFooter,
  NodeHeader,
  NodeTitle,
} from "@/components/pipecat/graph/node";

<GraphNode size="md">
  <NodeCard>
    <NodeHeader>
      <NodeTitle>Book appointment</NodeTitle>
    </NodeHeader>
    <NodeContent>Holds the slot the caller chose.</NodeContent>
    <NodeFooter>needs patient · slot</NodeFooter>
  </NodeCard>
</GraphNode>;

A node is markup and CSS: it draws no wires and holds no state. Ports go on its edges with Node Connector, and a Graph puts it on a canvas.

Parts

PartWhat it is
GraphNodeThe node's box: its width, its scale and the tracks the parts sit on. Paints nothing.
NodeCardThe surface: background, radius, ring.
NodeHeader, NodeContent, NodeFooterThe three rows. Leave any of them out and its row closes up.
NodeTitle, NodeDescriptionText, for a header or a footer.
NodeActionTrailing controls in a header, beside the title.
NodeExpandThe button that opens a subflow, for NodeAction.
NodeStatusBadgeThe chip on the top edge that says what the node is doing.

Parts are placed by name, so their order in the markup doesn't matter, and a node takes one of each. The middle row has a column either side of the content for connectors and is as tall as whichever is taller, so a node grows to fit its outputs.

Anything else you add, such as a selection ring, should be absolutely positioned so it stays out of the rows.

Why a box and a card

GraphNode is what a canvas positions and measures; NodeCard is what people see. Keeping them apart lets the card animate without moving the box, and connectors line up whether they sit inside the card or beside it:

<GraphNode>
  <NodeCard render={<motion.div whileHover={{ scale: 1.05 }} />}>
    <NodeHeader>…</NodeHeader>
    <NodeContent>…</NodeContent>
  </NodeCard>
  {/* Outside the card: the ports hold still while the card lifts. */}
  <NodeConnectorsRight>…</NodeConnectorsRight>
</GraphNode>

Leave the card's overflow visible, since ports straddle its edge. Give a height to GraphNode, not the card: the card fills the node's rows.

Sizes and width

size sets the node's width, padding and type together, and its connectors follow.

SizeWidthTitlePort
sm12rem12px10px
md15rem14px12px
lg18rem16px14px
xl22rem18px16px

A fluid node fills its parent instead, and its width is all that changes: the content takes up the slack, while type, padding and both connector areas stay as size set them.

<div className="w-96">
  <GraphNode fluid>…</GraphNode>
</div>

GraphNode is a size container named node, so content can respond to its width with @sm/node: variants. That also means it takes its width from size or its parent, never from its content.

Tones

tone colours a node from the palette. Its connectors take the tone, and so does anything you style with the tone utilities:

<GraphNode tone="green">
  <NodeCard>
    <NodeHeader>
      <NodeDescription className="text-graph-tone-ink">Book</NodeDescription>
    </NodeHeader>
    <NodeContent>
      <span className="bg-graph-tone-soft text-graph-tone-ink grid size-14 place-items-center rounded-2xl">
        <CalendarClockIcon />
      </span>
    </NodeContent>
  </NodeCard>
</GraphNode>

A node with no tone takes the one around it: its group's, its graph's, or neutral.

Subflows

A node that stands for a graph of its own is a subflow. The variant draws a stack of cards behind the node, in its tone. NodeExpand is its open button: you place it, because it needs a name and something to do.

<GraphNode variant="subflow" tone="purple">
  <NodeCard>
    <NodeHeader>
      <NodeTitle>Scheduling</NodeTitle>
      <NodeAction>
        <NodeExpand aria-label="Open Scheduling" onClick={open} />
      </NodeAction>
    </NodeHeader>
  </NodeCard>
</GraphNode>

The stack hangs below the node's box and takes no room in the layout. Give a subflow's ports the diamond shape to mark them as links into another graph.

Status

status shows what a call is doing at a node while it plays. The card changes to match:

StatusThe cardIts tone, unless set
idleAt rest.
activeA ring, and it pulses.The node's
guardA ring and a tint.amber
errorA ring and a tint, and it shakes once.red

A status has a tone apart from the node's, so the ports keep their colour. statusTone picks it from the palette, which lets one status stand for several things:

<GraphNode tone="blue" status="active" statusTone="coral">
  <NodeCard>…</NodeCard>
  <NodeStatusBadge>Listening</NodeStatusBadge>
</GraphNode>

NodeStatusBadge says the status in words, which colour alone doesn't. It sits on the node's top edge with a dot in the status tone, and pops in when it is added, so render it only while there is something to say. It isn't a live region: announce playback once for the canvas, not from every node.

To show the way a call left, set active on the connector and the wire it took. The shake and the pulse are skipped for people who ask for reduced motion.

Styling

Each part takes className, and a class you pass replaces the default it conflicts with. Geometry lives in variables on GraphNode:

VariableSets
--node-widthA fixed node's width.
--node-pxInline padding of the header, content and footer.
--node-pyBlock padding, and the space between rows.
--node-gapSpace between items inside a part.
--node-radiusThe card's corner radius.
--node-textBody text: the content and the footer.
--node-text-headerText in the header.
--node-text-descriptionDescriptions, wherever they sit.

Connectors keep their own variables.

<GraphNode className="[--node-px:--spacing(4)] [--node-radius:--spacing(6.5)]">
  <NodeCard className="shadow-lg ring-0">…</NodeCard>
</GraphNode>

Lengths are steps of Tailwind's --spacing, so setting --spacing on a node rescales it. The radius follows your theme's --radius unless you set it.

Every part carries a data-slot (node, node-card, node-header and so on). GraphNode also carries data-size, data-variant, data-fluid and data-tone, and data-status while its status isn't idle. Other state is yours to add: put data-selected or aria-disabled on GraphNode and style any part from it with group-data-selected/node:.

Restyle one status the same way, and reach its tone through --node-status. This card holds still while it is active:

<NodeCard className="group-data-[status=active]/node:animate-none">…</NodeCard>

A status's tint is its tone's -soft shade, so pin that to change it.

Every part also takes Base UI's render prop, to become a motion.div, a <section> or a link while keeping its slot, classes and handlers.

Key props

PropOnTypeDescription
sizeGraphNode"sm" | "md" | "lg" | "xl"Width, padding and type. Default md.
fluidGraphNodebooleanFill the parent's width. Nothing else changes size.
variantGraphNode"default" | "subflow"subflow draws a stack of cards behind the node.
toneGraphNodea palette tone, or your ownThe tone the node's parts and connectors take.
statusGraphNode"idle" | "active" | "guard" | "error"What a call is doing here. Default idle.
statusToneGraphNodea palette tone, or your ownThe status's tone. Default amber for a guard, red for an error, else the node's.
renderEvery partReactElement | functionRender the part as another element, keeping its attributes.

On this page