<MiniMap />
The <MiniMap /> component renders an overview of your flow. It renders each node
as an SVG element and visualizes where the current viewport is in relation to the
rest of the flow.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { MiniMap, VueFlow } from '@xyflow/vue';
const nodes = shallowRef([]);
const edges = shallowRef([]);
</script>
<template>
<VueFlow v-model:nodes="nodes" v-model:edges="edges">
<MiniMap :node-stroke-width="3" />
</VueFlow>
</template>Props
The type for props of <MiniMap /> component is exported as MiniMapProps.
| Name | Type | Default |
|---|---|---|
nodeColor | string | MiniMapNodeFuncColor of nodes on minimap. | |
nodeStrokeColor | string | MiniMapNodeFuncStroke color of nodes on minimap. | |
nodeClassName | string | MiniMapNodeFuncClass name applied to nodes on minimap. | |
nodeBorderRadius | numberBorder radius of nodes on minimap. | 5 |
nodeStrokeWidth | numberStroke width of nodes on minimap. | 2 |
bgColor | stringBackground color of minimap. | |
maskColor | stringThe color of the mask that covers the portion of the minimap not currently visible in the viewport. | |
maskStrokeColor | stringStroke color of mask representing viewport. | |
maskStrokeWidth | numberStroke width of mask representing viewport. Scaled by the minimap’s view scale, so the mask border keeps a constant on-screen thickness. | 1 |
position | PanelPositionPosition of minimap on pane, see PanelPosition . | 'bottom-right' |
pannable | booleanDetermines whether you can pan the viewport by dragging inside the minimap. | false |
zoomable | booleanDetermines whether you can zoom the viewport by scrolling inside the minimap. | false |
width | numberWidth of the mini map, in pixels. | 200 |
height | numberHeight of the mini map, in pixels. | 150 |
ariaLabel | string | nullAccessible label for the mini map. Pass | |
inversePan | booleanInvert direction when panning the minimap viewport. | |
zoomStep | numberStep size for zooming in/out on minimap. | 1 |
offsetScale | numberOffset the viewport on the minimap, acts like a padding. | 5 |
maskBorderRadius | numberBorder radius of the viewport mask, in pixels. | 0 |
onClick | ((params: { event: MouseEvent; position: XYPosition; }) => any) | undefined | |
onNodeClick | ((params: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>) => any) | undefined | |
onNodeDblclick | ((params: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>) => any) | undefined | |
onNodeMouseenter | ((params: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>) => any) | undefined | |
onNodeMousemove | ((params: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>) => any) | undefined | |
onNodeMouseleave | ((params: NodeMouseEvent<Node<Record<string, unknown>, string | undefined>>) => any) | undefined |
Examples
Making the mini map interactive
By default the mini map is non-interactive. Set either or both of pannable and
zoomable to true to let users pan and zoom the viewport from the mini map.
<template>
<VueFlow v-model:nodes="nodes" v-model:edges="edges">
<MiniMap pannable zoomable />
</VueFlow>
</template>Customizing mini map node color
nodeColor, nodeStrokeColor, and nodeClassName each accept a function that
receives a Node and returns the value for that node —
handy for coloring mini map nodes by type.
<script setup lang="ts">
import { MiniMap, VueFlow, type Node } from '@xyflow/vue';
function nodeColor(node: Node) {
return node.type === 'input' ? 'blue' : 'red';
}
</script>
<template>
<VueFlow v-model:nodes="nodes" v-model:edges="edges">
<MiniMap :node-color="nodeColor" />
</VueFlow>
</template>Notes
<MiniMap />emitsnode-click,node-double-click, and thenode-mouse-*events, each with the correspondingNode.- To render a custom shape per node, use the per-type
#node-*slots (e.g.#node-input), typed byMiniMapNodeProps.