Convert Figma logo to code with AI

bcakmakoglu logovue-flow

A highly customizable Flowchart component for Vue 3. Features seamless zoom & pan 🔎, additional components like a Minimap 🗺 and utilities to interact with state and graph.

3,702
241
3,702
11

Top Related Projects

4,650

Directed graph layout for JavaScript

11,025

♾ A Graph Visualization Framework in JavaScript.

Graph theory (network) library for visualisation and analysis

a super simple, no-nonsense diagramming library written in react that just works

25,227

React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.

6,804

mxGraph is a fully client side JavaScript diagramming library

Quick Overview

Vue Flow is a highly customizable Vue 3 component library for building node-based editors, flow charts, and interactive diagrams. It provides a powerful set of tools for creating and manipulating nodes, edges, and the overall graph structure, making it ideal for complex visualization and interaction scenarios.

Pros

  • Highly customizable with a wide range of options for nodes, edges, and graph behavior
  • Built specifically for Vue 3, leveraging its reactivity system and composition API
  • Excellent performance, even with large numbers of nodes and edges
  • Comprehensive documentation and examples

Cons

  • Steep learning curve for complex implementations
  • Limited built-in layouts compared to some other graph libraries
  • Requires careful state management for large-scale applications
  • Some advanced features may require additional plugins or custom development

Code Examples

  1. Creating a basic flow with nodes and edges:
<template>
  <VueFlow v-model="elements" />
</template>

<script setup>
import { ref } from 'vue'
import { VueFlow } from '@vue-flow/core'

const elements = ref([
  { id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
  { id: '2', label: 'Node 2', position: { x: 100, y: 100 } },
  { id: 'e1-2', source: '1', target: '2', animated: true }
])
</script>
  1. Adding custom node types:
<template>
  <VueFlow v-model="elements" :node-types="nodeTypes" />
</template>

<script setup>
import { ref } from 'vue'
import { VueFlow } from '@vue-flow/core'
import CustomNode from './CustomNode.vue'

const nodeTypes = {
  custom: CustomNode
}

const elements = ref([
  { id: '1', type: 'custom', data: { label: 'Custom Node' }, position: { x: 250, y: 5 } }
])
</script>
  1. Using the useVueFlow composable for programmatic control:
<script setup>
import { onMounted } from 'vue'
import { useVueFlow } from '@vue-flow/core'

const { findNode, addEdge } = useVueFlow()

onMounted(() => {
  const node = findNode('1')
  if (node) {
    addEdge({ id: 'e1-3', source: '1', target: '3' })
  }
})
</script>

Getting Started

  1. Install Vue Flow:

    npm install @vue-flow/core
    
  2. Import and use in your Vue component:

    <template>
      <VueFlow v-model="elements" />
    </template>
    
    <script setup>
    import { ref } from 'vue'
    import { VueFlow } from '@vue-flow/core'
    import '@vue-flow/core/dist/style.css'
    
    const elements = ref([
      { id: '1', label: 'Node 1', position: { x: 100, y: 100 } },
      { id: '2', label: 'Node 2', position: { x: 200, y: 200 } },
      { id: 'e1-2', source: '1', target: '2' }
    ])
    </script>
    
  3. Customize as needed, referring to the documentation for advanced features and options.

Competitor Comparisons

4,650

Directed graph layout for JavaScript

Pros of dagre

  • Language-agnostic graph layout library, usable in various environments
  • Highly customizable with numerous layout options and algorithms
  • Well-established project with extensive documentation and community support

Cons of dagre

  • Requires additional integration work for use in Vue.js applications
  • Less intuitive for Vue developers compared to a Vue-specific solution
  • May have performance limitations for very large graphs

Code Comparison

dagre:

var g = new dagre.graphlib.Graph();
g.setNode("kspacey", { label: "Kevin Spacey", width: 144, height: 100 });
g.setNode("swilliams", { label: "Saul Williams", width: 160, height: 100 });
g.setEdge("kspacey", "swilliams");
dagre.layout(g);

vue-flow:

<template>
  <VueFlow v-model="elements" :fit-view-on-init="true">
    <Background />
    <MiniMap />
    <Controls />
  </VueFlow>
</template>

Summary

dagre is a versatile graph layout library suitable for various environments, offering extensive customization options. However, it requires additional integration work for Vue.js applications. vue-flow, on the other hand, provides a more Vue-friendly solution with built-in components and easier integration, but may have limitations in terms of layout algorithms and customization compared to dagre.

11,025

♾ A Graph Visualization Framework in JavaScript.

Pros of G6

  • More comprehensive and feature-rich graph visualization library
  • Supports a wider range of graph types and layouts
  • Better performance for large-scale graph rendering

Cons of G6

  • Steeper learning curve due to its extensive API and features
  • Less seamless integration with Vue.js compared to Vue Flow
  • Requires more setup and configuration for basic use cases

Code Comparison

G6:

import G6 from '@antv/g6';

const graph = new G6.Graph({
  container: 'mountNode',
  width: 800,
  height: 600,
});

graph.data(data);
graph.render();

Vue Flow:

<template>
  <VueFlow v-model="elements" />
</template>

<script setup>
import { VueFlow } from '@vue-flow/core';
import { ref } from 'vue';

const elements = ref([]);
</script>

G6 offers a more powerful and flexible API for creating complex graph visualizations, while Vue Flow provides a more Vue-centric approach with easier integration into Vue.js applications. G6 excels in performance and advanced graph rendering capabilities, making it suitable for large-scale and complex graph visualizations. Vue Flow, on the other hand, offers a more straightforward setup and usage within Vue.js projects, making it ideal for simpler graph implementations and rapid prototyping.

Graph theory (network) library for visualisation and analysis

Pros of Cytoscape.js

  • More mature and feature-rich library with extensive documentation
  • Supports a wider range of graph types and layouts
  • Larger community and ecosystem with numerous extensions

Cons of Cytoscape.js

  • Steeper learning curve due to its complexity
  • Not specifically designed for Vue.js integration
  • Heavier in terms of file size and performance impact

Code Comparison

Vue-flow:

<template>
  <VueFlow v-model="elements" @nodeClick="onNodeClick">
    <Background />
    <MiniMap />
    <Controls />
  </VueFlow>
</template>

Cytoscape.js:

const cy = cytoscape({
  container: document.getElementById('cy'),
  elements: [
    { data: { id: 'a' } },
    { data: { id: 'b' } },
    { data: { id: 'ab', source: 'a', target: 'b' } }
  ],
  style: [ /* ... */ ],
  layout: { name: 'grid' }
});

Vue-flow is specifically designed for Vue.js applications, offering a more intuitive and declarative approach to creating flow diagrams. It provides Vue-specific components and integrates seamlessly with Vue's reactivity system.

Cytoscape.js, on the other hand, is a more powerful and versatile graph theory library that can be used in various JavaScript environments. It offers more advanced features and customization options but requires more setup and configuration when used in a Vue.js project.

a super simple, no-nonsense diagramming library written in react that just works

Pros of react-diagrams

  • More mature and feature-rich library with a larger community
  • Extensive documentation and examples available
  • Built-in support for custom node types and link routing

Cons of react-diagrams

  • Steeper learning curve due to its complexity
  • Heavier bundle size compared to vue-flow
  • Less flexible styling options out of the box

Code Comparison

react-diagrams:

import { DiagramEngine, DiagramModel, DefaultNodeModel } from '@projectstorm/react-diagrams';

const engine = new DiagramEngine();
const model = new DiagramModel();
const node1 = new DefaultNodeModel('Node 1', 'rgb(0,192,255)');
model.addNode(node1);
engine.setModel(model);

vue-flow:

<template>
  <VueFlow v-model="elements">
    <MiniMap />
    <Controls />
    <Background />
  </VueFlow>
</template>

<script setup>
import { ref } from 'vue';
import { VueFlow, MiniMap, Controls, Background } from '@vue-flow/core';

const elements = ref([
  { id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
]);
</script>

Both libraries offer powerful diagramming capabilities, but react-diagrams provides more built-in features at the cost of complexity, while vue-flow offers a simpler API and better integration with Vue.js projects.

25,227

React Flow | Svelte Flow - Powerful open source libraries for building node-based UIs with React (https://reactflow.dev) or Svelte (https://svelteflow.dev). Ready out-of-the-box and infinitely customizable.

Pros of xyflow

  • More comprehensive and feature-rich, supporting React, Vue, and Svelte
  • Larger community and more frequent updates
  • Better documentation and examples

Cons of xyflow

  • Steeper learning curve due to its broader scope
  • Potentially more complex setup for Vue-specific projects
  • Larger bundle size due to multi-framework support

Code Comparison

xyflow (React example):

import ReactFlow from 'reactflow';

export default function Flow() {
  return <ReactFlow elements={elements} />;
}

vue-flow:

<template>
  <VueFlow v-model="elements" />
</template>

<script setup>
import { VueFlow } from '@vue-flow/core';
</script>

Summary

xyflow offers a more comprehensive solution for building node-based editors and interactive diagrams across multiple frameworks, including React, Vue, and Svelte. It benefits from a larger community, more frequent updates, and better documentation. However, this broader scope can lead to a steeper learning curve and potentially more complex setup for Vue-specific projects.

vue-flow, on the other hand, is tailored specifically for Vue.js, offering a more straightforward integration for Vue developers. It may have a smaller feature set and community compared to xyflow, but it provides a more focused and potentially easier-to-use solution for Vue applications.

The choice between the two depends on the specific project requirements, the preferred framework, and the need for cross-framework compatibility.

6,804

mxGraph is a fully client side JavaScript diagramming library

Pros of mxgraph

  • More mature and feature-rich library with extensive documentation
  • Supports a wider range of diagram types and use cases
  • Offers both client-side and server-side rendering options

Cons of mxgraph

  • Steeper learning curve due to its complexity and extensive API
  • Larger file size and potentially heavier performance impact
  • Less seamless integration with Vue.js compared to vue-flow

Code Comparison

mxgraph:

var graph = new mxGraph(container);
var parent = graph.getDefaultParent();
graph.getModel().beginUpdate();
try {
  var v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30);
  var v2 = graph.insertVertex(parent, null, 'World!', 200, 150, 80, 30);
  var e1 = graph.insertEdge(parent, null, '', v1, v2);
} finally {
  graph.getModel().endUpdate();
}

vue-flow:

<template>
  <VueFlow v-model="elements">
    <Background />
    <MiniMap />
    <Controls />
  </VueFlow>
</template>

<script setup>
import { ref } from 'vue';
const elements = ref([
  { id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
  { id: '2', label: 'Node 2', position: { x: 100, y: 100 } },
  { id: 'e1-2', source: '1', target: '2', animated: true },
]);
</script>

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Vue Flow 🌊

Vue flow top-language GitHub code size in bytes GitHub last commit

Vue Flow: A highly customizable Vue 3 Flowchart component.

You can find a detailed explanation on how to get started here or jump right into the examples.

Table of contents

⭐️ Features

  • 👶 Easy setup: Get started hassle-free - Built-in zoom- & pan features, element dragging, selection and much more

  • 🎨 Customizable: Use your custom nodes, edges and connection lines and expand on Vue Flows' functionality

  • 🚀 Fast: Tracks changes reactively and only re-renders the appropriate elements

  • 🧲 Utils & Composition: Comes with graph helper and state composable functions for advanced uses

  • 📦 Additional Components:

    • 🖼 Background: With two built-in patterns and some configuration options like height, width or color.

    • 🧭 Minimap: Shows current nodes in a small map shape in the bottom right corner

    • 🕹 Controls: Control zoom behavior from a panel on the bottom left

    • 🤖 And (many) more to come...

  • 🦾 Reliable: Fully written in TypeScript

🛠 Setup

$ npm i @vue-flow/core

# or
$ pnpm i @vue-flow/core

# or
$ yarn add @vue-flow/core

🎮 Quickstart

In Vue Flow, an application structure consists of nodes and edges, all of which are categorised as elements.

Each element requires a unique id.

Nodes additionally need an XY-position, while edges require a source and a target, both represented by node ids.

<!-- Flowchart.vue -->
<script setup>
import { ref } from 'vue'  
import { VueFlow } from '@vue-flow/core'

const nodes = ref([
  { id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
  { id: '2', label: 'Node 2', position: { x: 100, y: 100 } },
  { id: '3', label: 'Node 3', position: { x: 400, y: 100 } },
  { id: '4', label: 'Node 4', position: { x: 400, y: 200 } },
])
  
const edges = ref([
  { id: 'e1-2', source: '1', target: '2', animated: true },
  { id: 'e1-3', source: '1', target: '3' },
])
</script>

<template>
  <VueFlow v-model:nodes="nodes" v-model:edges="edges"></VueFlow>
</template>

⚠️ Make sure to import the necessary styles:

/* import the required styles */
@import "@vue-flow/core/dist/style.css";

/* import the default theme (optional) */
@import "@vue-flow/core/dist/theme-default.css";

Do not scope these styles with scoped in your component.

🪴 Vue 2

This library doesn't work with Vue 2.

Vue Flow uses features that are exclusive to Vue 3, therefore there is no support for Vue 2, nor will there be any support in the future, sorry.

🧪 Development

Prerequisites

# install pnpm if you haven't already
$ npm i -g pnpm

# start examples
$ pnpm dev

# build all packages
$ pnpm build

🐳 Dev Container

To start using development containers, install the Docker extension for VSCode. After installing the extension, open the connection menu either on the bottom left or open it via the commands tab. Select the Open Folder in Container option to mount the project.

The development container will spin up all packages example apps and forward the ports to your machine.

discord logo Discord

Join the Vue Flow Discord server!

Here you can ask questions to the community, propose ideas for new features or share your work that you have built with Vue Flow.

💝 Special Thanks

This project is built with

  • React Flow

    • Vue flow is heavily based on webkids' ReactFlow. I wholeheartedly thank them for their amazing work! Without them VueFlow would not exist. Please consider donating or subscribing to ReactFlow Pro.
  • D3.js

    • D3 makes all the zoom and pan actions in Vue Flow possible.
  • VueUse

    • VueUse is a collection of essential vue composition utilities

⭐ Stargazers

Many thanks to the kind individuals who leave a star. Your support is much appreciated!

Stargazers for @vue-flow/core

NPM DownloadsLast 30 Days