react-flow
БесплатноБез исполняемых скриптовНе проверенImplements and structures node-based UIs with React Flow (@xyflow/react v12/v13), covering custom nodes and edges, handles, viewport control, sub-flows, store…
от existential-birds★ 92 звезды на GitHubОб этом скилле
React Flow (@xyflow/react)
Implement interactive node-based graphs and workflow editors using @xyflow/react (v12 and v13, React 18/19).
Implementation Gates
Run these checks in order before treating any integration as complete:
- CSS & container dimensions — Import
@xyflow/react/style.css(v13, wrapped in@layer xyflowfor Tailwind v4 precedence) or@xyflow/react/dist/style.css(v12), and give the wrapper element explicit dimensions (widthandheight). - Stable
nodeTypes/edgeTypes— DefinenodeTypesandedgeTypesat module scope or memoize withuseMemo; never create inline object literals on every render (causes full node/edge remounting). - Provider boundary — Any component calling
useReactFlow(),useNodesData(),useNodeConnections(), or store hooks must be a descendant of<ReactFlowProvider>(or rendered inside<ReactFlow />). - Measured vs SSR dimensions — Read DOM-measured node sizes from
node.measured?.width/node.measured?.height(falling back tonode.width ?? defaultWidth). For SSR/SSG, provide staticwidth/heightorinitialWidth/initialHeighton nodes sofitViewand initial layout work without DOM measurement.
Quick Start & TypeScript Unions
import { useCallback } from 'react';
import {
ReactFlow,
ReactFlowProvider,
Background,
Controls,
useNodesState,
useEdgesState,
addEdge,
type Node,
type Edge,
type BuiltInNode,
type BuiltInEdge,
type OnConnect,
} from '@xyflow/react';
import '@xyflow/react/style.css'; // v13 (@layer xyflow); use '@xyflow/react/dist/style.css' on v12
export type TaskNode = Node<{ label: string; active: boolean }, 'task'>;
export type AppNode = BuiltInNode | TaskNode;
export type WeightedEdge = Edge<{ weight: number }, 'weighted'>;
export type AppEdge = BuiltInEdge | WeightedEdge;
const nodeTypes = { /* task: TaskNodeComponent */ };
const edgeTypes = { /* weighted: WeightedEdgeComponent */ };
const initialNodes: AppNode[] = [
{ id: '1', type: 'input', position: { x: 0, y: 0 }, data: { label: 'Start' } },
{ id: '2', position: { x: 240, y: 80 }, data: { label: 'Process' } },
];
const initialEdges: AppEdge[] = [{ id: 'e1-2', source: '1', target: '2' }];
function FlowCanvas() {
const [nodes, setNodes, onNodesChange] = useNodesState<AppNode>(initialNodes);
const [edges, setEdges, onEdgesChange] = useEdgesState<AppEdge>(initialEdges);
const onConnect: OnConnect = useCallback(
(connection) => setEdges((eds) => addEdge(connection, eds)),
[setEdges]
);
return (
<div style={{ width: '100%', height: '100vh' }}>
<ReactFlow
nodes={nodes}
edges={edges}
nodeTypes={nodeTypes}
edgeTypes={edgeTypes}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onConnect={onConnect}
fitView
>
<Background />
<Controls />
</ReactFlow>
</div>
);
}
export default function App() {
return (
<ReactFlowProvider>
<FlowCanvas />
</ReactFlowProvider>
);
}
Custom Nodes, Edges & Interaction Classes
- Typed props: Use
NodeProps<TaskNode>andEdgeProps<WeightedEdge>, wrapped inmemo(). ImportCSSPropertiesfrom'react'(not'@xyflow/react'). - Handles: Always use
Positionenum (Position.Top,Position.Right,Position.Bottom,Position.Left). Assign distinctidprops when a node has multiple handles of the same type, and match them viasourceHandle/targetHandleon edges. - Interaction classes: Prevent accidental graph interactions on embedded controls:
nodrag— prevents dragging the node (required on<input>,<button>,<select>)nopan— prevents canvas panning from the elementnowheel— prevents canvas zoom on scroll inside scrollable areasnokey— prevents React Flow keyboard shortcuts (backspace/delete) when typing in inputs
For multi-handle nodes, dynamic handles (useUpdateNodeInternals), NodeToolbar, NodeResizer, EdgeToolbar, Panel, BaseEdge, EdgeLabelRenderer, EdgeText, MarkerType, and onBeforeDelete, see Custom Primitives.
Core APIs & Patterns
Updating Node/Edge Data & Reconnecting
Prefer useReactFlow().updateNodeData / updateEdgeData over manually mapping the full nodes/edges array for data-only updates:
const { updateNodeData, setEdges } = useReactFlow<AppNode, AppEdge>();
// Merge partial data (or pass { replace: true } as 3rd arg); generics live on useReactFlow<AppNode, AppEdge>()
updateNodeData('node-1', { active: true });
// Functional updater on union AppNode: narrow node.type before reading custom fields
updateNodeData('node-1', (node) => {
if (node.type !== 'task') return node.data;
return { ...node.data, active: !node.data.active };
});
Use reconnectEdge with onReconnect (replaced v11's updateEdge utility):
import { reconnectEdge, type OnReconnect
Установить react-flow в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл react-flow?
Implements and structures node-based UIs with React Flow (@xyflow/react v12/v13), covering custom nodes and edges, handles, viewport control, sub-flows, store subscriptions, and @dagrejs/dagre auto-layout. Use when building flow editors, workflow diagrams, or interactive graphs in React.
Как установить скилл react-flow?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react-flow запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic