Labeled Group Node
A group node with an optional label.
Installation
Make sure to follow the prerequisites before installing the component.
npx shadcn@latest add https://ui.reactflow.dev/labeled-group-node
Usage
1. Copy the component into your app
import { memo } from "react";
import { NodeProps } from "@xyflow/react";
import { GroupNode } from "@/components/labeled-group-node";
const LabeledGroupNodeDemo = memo(({ selected }: NodeProps) => {
return <GroupNode selected={selected} label="Label" />;
});
export default LabeledGroupNodeDemo;
2. Connect the component with your React Flow application.
import { Background, ReactFlow, Node } from "@xyflow/react";
import LabeledGroupNodeDemo from "./component-example";
const nodeTypes = {
labeledGroupNode: LabeledGroupNodeDemo,
};
const defaultNodes: Node[] = [
{
id: "1",
position: { x: 200, y: 200 },
data: { label: "Group Node" },
width: 380,
height: 200,
type: "labeledGroupNode",
},
{
id: "2",
position: { x: 50, y: 100 },
data: { label: "Node" },
type: "default",
parentId: "1",
extent: "parent",
},
{
id: "3",
position: { x: 200, y: 50 },
data: { label: "Node" },
type: "default",
parentId: "1",
extent: "parent",
},
];
export default function App() {
return (
<div className="h-full w-full">
<ReactFlow defaultNodes={defaultNodes} nodeTypes={nodeTypes} fitView>
<Background />
</ReactFlow>
</div>
);
}
Last updated on