<MiniMap />
The Minimap component adds an interactive Minimap to React Flow that shows the whole graph. You can use the MiniMap
plugin by passing it as a children to the ReactFlow
component.
The minimap is not interactive by default. If you want to control the viewport with the mini map, you need to pass zoomable
and pannable
.
Usage Example
Prop Types
pannable?
boolean
false
zoomable?
boolean
false
nodeColor?
string | (node: Node) => string
#fff
nodeStrokeColor?
string | (node: Node) => string
#555
nodeBorderRadius?
number
5
nodeStrokeWidth?
number
2
nodeClassName?
string | (node: Node) => string
nodeComponent?
React.ComponentType(MiniMapNodeProps)
maskColor?
string
"rgb(240, 242, 243, 0.7)"
maskStrokeColor?
string
"none"
maskStrokeWidth?
number
1
inversePan?
boolean
false
zoomStep?
number
10
onClick?
(event: React.MouseEvent, position: XYPosition) => void
onNodeClick?
(event: React.MouseEvent, node: Node) => void
ariaLabel?
string | null
"React Flow mini map"
style?
CSSProperties
className?
string
position?
Custom MiniMap Nodes
You can swap out the default component used for nodes in the minimap with whatever
you want by setting the nodeComponent
prop on the <MiniMap />
component. Below
is the same example as before, but now we're rendering a circle
instead of a rectangle!
For performance reasons, the minimap is rendered as an SVG. This means that you must use SVG elements for your custom node component if you want it to work properly.
Custom Node Prop Types
id
string
x
number
y
number
width
number
height
number
borderRadius
nodeBorderRadius
prop of the MiniMap
component.number
className
nodeClassName
prop of the MiniMap
component.string
color
nodeColor
prop of the <MiniMap />
component, or the color computed by the function passed in instead.string
shapeRendering
"crispEdges" | "geometricPrecision"
strokeColor
nodeStrokeColor
prop of the MiniMap
component.string
strokeWidth
nodeStrokeWidth
prop of the MiniMap
component.',number
style
CSSProperties
onClick
(event: React.MouseEvent, id: string) => void
Typescript
The interface of both the <MiniMap />
and custom node props are exported as MiniMapProps
and MiniMapNodeProps
respectively.
Npm Package
The minimap component is published under @reactflow/minimap
and can also be installed and used separately.