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.
Installation
pnpm dlx shadcn@latest add @pipecat/graph-nodeAlso 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
| Part | What it is |
|---|---|
GraphNode | The node's box: its width, its scale and the tracks the parts sit on. Paints nothing. |
NodeCard | The surface: background, radius, ring. |
NodeHeader, NodeContent, NodeFooter | The three rows. Leave any of them out and its row closes up. |
NodeTitle, NodeDescription | Text, for a header or a footer. |
NodeAction | Trailing controls in a header, beside the title. |
NodeExpand | The button that opens a subflow, for NodeAction. |
NodeStatusBadge | The 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.
| Size | Width | Title | Port |
|---|---|---|---|
sm | 12rem | 12px | 10px |
md | 15rem | 14px | 12px |
lg | 18rem | 16px | 14px |
xl | 22rem | 18px | 16px |
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:
| Status | The card | Its tone, unless set |
|---|---|---|
idle | At rest. | |
active | A ring, and it pulses. | The node's |
guard | A ring and a tint. | amber |
error | A 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:
| Variable | Sets |
|---|---|
--node-width | A fixed node's width. |
--node-px | Inline padding of the header, content and footer. |
--node-py | Block padding, and the space between rows. |
--node-gap | Space between items inside a part. |
--node-radius | The card's corner radius. |
--node-text | Body text: the content and the footer. |
--node-text-header | Text in the header. |
--node-text-description | Descriptions, 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
| Prop | On | Type | Description |
|---|---|---|---|
size | GraphNode | "sm" | "md" | "lg" | "xl" | Width, padding and type. Default md. |
fluid | GraphNode | boolean | Fill the parent's width. Nothing else changes size. |
variant | GraphNode | "default" | "subflow" | subflow draws a stack of cards behind the node. |
tone | GraphNode | a palette tone, or your own | The tone the node's parts and connectors take. |
status | GraphNode | "idle" | "active" | "guard" | "error" | What a call is doing here. Default idle. |
statusTone | GraphNode | a palette tone, or your own | The status's tone. Default amber for a guard, red for an error, else the node's. |
render | Every part | ReactElement | function | Render the part as another element, keeping its attributes. |