useEdge()
The useEdge composable returns the Edge for a given id
along with its DOM element. Inside a custom edge
the id defaults to the current edge, so you can call it with no arguments.
<!-- CustomEdge.vue -->
<script setup lang="ts">
import { useEdge } from '@xyflow/vue';
const { edge, edgeEl } = useEdge();
</script>Signature
Parameters:| Name | Type | Default |
|---|---|---|
id | stringThe id of the edge to access |
the edge id, the edge (a ComputedRef) and the edge dom element
| Name | Type |
|---|---|
id | string |
edge | ComputedRef<EdgeType | undefined> |
edgeEl | ShallowRef<SVGElement | null, SVGElement | null> |
Notes
edgeElis only populated whenuseEdgeruns inside a custom edge (or a descendant of one) — it’s injected from the surrounding edge’s component. Called from anywhere else, theedgedata still resolves byid, butedgeElstaysnull. Note it always refers to the edge you’re rendered in, not the edge theidargument points at.