Pipecat UI
Graph

Node Group

A group of nodes — a tinted island around them and a name tag on its top edge — that hugs what is inside it or takes its size from a canvas.

View in Storybook
Book it

Installation

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

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

This installs Tones too, the palette a group takes its tone from. It doesn't need a Graph: a group works anywhere nodes do.

Usage

import { GripVerticalIcon } from "lucide-react";

import {
  NodeGroup,
  NodeGroupHandle,
  NodeGroupIsland,
  NodeGroupTag,
  NodeGroupTitle,
} from "@/components/pipecat/graph/node-group";

<NodeGroup tone="blue">
  <NodeGroupTag>
    <NodeGroupHandle>
      <GripVerticalIcon aria-hidden />
      <NodeGroupTitle>Book it</NodeGroupTitle>
    </NodeGroupHandle>
  </NodeGroupTag>
  <NodeGroupIsland className="grid-flow-col gap-10">
    <GraphNode>…</GraphNode>
    <GraphNode>…</GraphNode>
  </NodeGroupIsland>
</NodeGroup>;

A group is markup and CSS only. It doesn't work out which nodes belong to it, follow them or move them: that is the canvas's job.

Parts

PartWhat it is
NodeGroupThe group's box: its size, its tone and the scale of its parts. Paints nothing.
NodeGroupIslandThe tinted region behind the group's nodes.
NodeGroupTagThe name tag. It straddles the island's top edge, in from the left corner.
NodeGroupHandleThe part of the tag a group is dragged by: a grip, the name.
NodeGroupTitleThe group's name, after a dot in its tone.
NodeGroupEmptyWhat an empty group shows in the middle of its island.
NodeGroupAddThe button an empty group starts from, in its tone.

The tag is a row. Anything you put in it after the handle, such as a menu or an add button, lines up beside the name. The handle only looks grabbable; point your canvas's drag handle at it.

Around its nodes

Put nodes inside NodeGroupIsland and the group hugs them. The island is a grid, so grid-flow-col and a gap lay them out in a row.

On a canvas

On a Graph, a group is a node type. Fill the size React Flow gives it and leave the island bare; the group's children are drawn over it. Point the node's dragHandle at the handle, so the group is dragged by its tag and the canvas still pans from the island.

function Group({ data }: NodeProps<GroupNode>) {
  return (
    <NodeGroup tone={data.tone} className="size-full">
      <NodeGroupTag>
        <NodeGroupHandle>
          <GripVerticalIcon aria-hidden />
          <NodeGroupTitle>{data.title}</NodeGroupTitle>
        </NodeGroupHandle>
      </NodeGroupTag>
      <NodeGroupIsland />
    </NodeGroup>
  );
}

const nodes = [
  { id: "book", type: "group", dragHandle: "[data-slot=node-group-handle]", … },
  { id: "find", type: "step", parentId: "book", position: { x: 24, y: 48 }, … },
];

With packGrid on the graph, the group sizes itself around its children.

Sizes

size steps the island's padding and radius and the tag's type together. Match it to the nodes inside.

SizePaddingTag text
sm16px12px
md24px14px
lg32px16px
xl40px18px

The island's top padding is twice the rest, to clear the tag.

Tone

tone colours the island and the tag's dot from the palette. Nodes inside the island take the group's tone unless they name their own.

An empty group

empty outlines the island, pads it evenly and gives it a size to wait at. NodeGroupEmpty sits in its centre, with whatever starts the group off. NodeGroupAdd is a button for that, in the group's tone: dashed at rest, tinted under the pointer, and filled while it has a menu or popover open.

<NodeGroup tone="green" empty>
  <NodeGroupTag>…</NodeGroupTag>
  <NodeGroupIsland>
    <NodeGroupEmpty>
      <NodeGroupAdd aria-label="Add a step to Book it" onClick={add} />
      Add a step, or drop one here
    </NodeGroupEmpty>
  </NodeGroupIsland>
</NodeGroup>

Styling

Each part takes className and Base UI's render prop, and carries a data-slot (node-group, node-group-island, node-group-tag and so on). NodeGroup also carries data-size, data-tone and data-empty. Other state is yours to add: put data-locked on NodeGroup and style any part from it with group-data-locked/node-group:.

Sizes live in variables on NodeGroup:

VariableSets
--node-group-pxThe island's inline padding, and how far in the tag sits.
--node-group-pyThe island's block padding. The top is twice this.
--node-group-radiusThe island's corner radius.
--node-group-textThe tag's text.
<NodeGroup className="[--node-group-radius:--spacing(8.5)]">
  <NodeGroupTag className="shadow-md ring-0">…</NodeGroupTag>
  <NodeGroupIsland>…</NodeGroupIsland>
</NodeGroup>

Key props

PropOnTypeDescription
sizeNodeGroup"sm" | "md" | "lg" | "xl"The island's padding and radius, the tag's type.
toneNodeGroupa palette tone, or your ownThe tone of the island, the dot and everything inside.
emptyNodeGroupbooleanOutlines the island and gives it a size to wait at.
renderEvery partReactElement | functionRender the part as another element, keeping its attributes.

On this page