Edge

Customizable edge components for Vue Flow canvases with animated and temporary states.

The Edge component provides two pre-styled edge types for Vue Flow canvases: Temporary for dashed temporary connections and Animated for connections with animated indicators.

Install using CLI

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add edge

Install Manually

Copy and paste the following code in the same folder.

Temporary.vue
Animated.vue
index.ts
<script setup lang="ts">
import type { EdgeProps } from '@vue-flow/core'
import { BaseEdge, getSimpleBezierPath } from '@vue-flow/core'
import { computed } from 'vue'

const props = defineProps<EdgeProps>()

const path = computed(() => {
  const [edgePath] = getSimpleBezierPath({
    sourceX: props.sourceX,
    sourceY: props.sourceY,
    sourcePosition: props.sourcePosition,
    targetX: props.targetX,
    targetY: props.targetY,
    targetPosition: props.targetPosition,
  })
  return edgePath
})
</script>

<template>
  <BaseEdge
    :id="props.id"
    :path="path"
    class="stroke-1 stroke-ring"
    :style="{ strokeDasharray: '5, 5' }"
  />
</template>

Features

  • Two distinct edge types: Temporary and Animated
  • Temporary edges use dashed lines with ring color
  • Animated edges include a moving circle indicator
  • Automatic handle position calculation
  • Smart offset calculation based on handle type and position
  • Uses Bezier curves for smooth, natural-looking connections
  • Fully compatible with Vue Flow's edge system
  • Type-safe implementation with TypeScript

Edge Types

<Temporary />

A dashed edge style for temporary or preview connections. Uses a simple Bezier path with a dashed stroke pattern.

<Animated />

A solid edge with an animated circle that moves along the path. The animation repeats indefinitely with a 2-second duration, providing visual feedback for active connections.

Props

Both <Animated /> and <Temporary /> components accept standard Vue Flow EdgeProps. The following are the most commonly used props:

idstring
The unique identifier for the edge.
sourcestring
The ID of the source node.
targetstring
The ID of the target node.
sourceXnumber
The x-coordinate of the source connection point.
sourceYnumber
The y-coordinate of the source connection point.
targetXnumber
The x-coordinate of the target connection point.
targetYnumber
The y-coordinate of the target connection point.
sourcePositionPosition
The position of the source handle.
targetPositionPosition
The position of the target handle.
styleCSSProperties
Custom CSS styles to apply to the edge.
markerStartstring
The marker ID for the start of the edge.
markerEndstring
The marker ID for the end of the edge.