Skip to Content
Vue Flow v2 is here and joins xyflow! Read more here →

<EdgeText />

Source on GitHub 

The <EdgeText /> component renders a label with an optional background at a given position. It is used by <BaseEdge /> to draw edge labels, and you can use it directly in a custom edge.

<!-- CustomEdge.vue --> <script setup lang="ts"> import { BaseEdge, EdgeText, getBezierPath, type EdgeProps } from '@xyflow/vue'; import { computed } from 'vue'; const props = defineProps<EdgeProps>(); const path = computed(() => getBezierPath(props)); </script> <template> <BaseEdge :id="id" :path="path[0]" /> <EdgeText :x="path[1]" :y="path[2]" label="custom label" /> </template>

Props

The type for props of <EdgeText /> component is exported as EdgeTextProps.

NameTypeDefault
xnumber

The x position where the label should be rendered.

ynumber

The y position where the label should be rendered.

labelstring | VNode<RendererNode, RendererElement, { [key: string]: any; }> | Component

The label or custom element to render along the edge. This is commonly a text label or some custom controls.

labelStyleCSSProperties

Custom styles to apply to the label.

labelShowBgboolean

Render a background rectangle behind the label.

true
labelBgStyleCSSProperties

Inline style applied to the label background rectangle.

labelBgPadding[number, number]

Padding around the label inside its background, as [x, y] in pixels.

[2, 4]
labelBgBorderRadiusnumber

Border radius of the label background, in pixels.

2