Blazor Mind Map
The Blazor Bootstrap Mind Map component shows hierarchical data as a collapsible node-link tree that grows right, left, to both sides, down, or up. The examples below cover directions, node template, branch colors, expansion and selection and path.
INFO
On a prerendered or static page, MindMap first shows the tree read-only. The +/− controls, find box, zoom, and keyboard support start once the page is interactive.
Basic usage #
MindMap draws one root item and its descendants as a collapsible node-link tree, with a line from each parent to each child.
How to use:
Click + or − on a card to open or close it. By default only the root starts open.
How to use:
- Add
MindMapand setTItemto your item type. - Set
Rootto the central item. - Set
Childrento a selector that returns an item's children, andLabelto a selector that returns its text. - Name the map for screen readers with
aria-labeloraria-labelledby.
Directions #
Branches grow to the right by default.
How to use:
Pick a direction below to see the same plan laid out each way.
Direction can make them grow left, to both sides of a central root, down, or up.
How to use:
- Set
Directionto aMindMapDirectionvalue:Right,Left,BothSides,Down, orUp. - With
BothSides, first-level branches are split between the right and left so both sides hold a similar number of nodes.
Node template #
NodeTemplate fills each card with your own markup. The component still draws the card frame, the +/− control, and the lines.
How to use:
- Add a
NodeTemplateand name its context, for exampleContext="node". - Read the item from
node.Itemand render any markup, such asBadgecomponents. - Keep
Labelset: search, the path bar, and screen readers use it.
Branch colors #
Each first-level branch takes the next Bootstrap palette color, and its descendants share it. Your data can pin a color for any branch.
How to use:
Here Risks is pinned to red, and the switch turns automatic colors off.
How to use:
- Leave
AutoBranchColorson for automatic colors, or set it tofalsefor neutral lines. - Set
BranchColorto a selector that returns aMindMapColorfor an item, ornullto keep the automatic color.
Expansion #
Bind the open nodes to read, set, save, or restore them, and react to each change.
How to use:
The lines under the map show the bound set and the last change.
How to use:
- Bind the open nodes with
@bind-ExpandedItems. Without a binding,InitialExpandDepthdecides which nodes start open. - Call
ExpandAllAsync()orCollapseAllAsync()through a component reference. - Handle
OnExpandedChangedto see which nodes opened and closed in each change.
Selection and path #
Clicking a card, or pressing Enter or Space on it, selects it. The path bar under the map shows the way from the root to the selected node.
How to use:
Selecting a node does not open or close it. Only the +/− control does that.
How to use:
- Bind the selected item with
@bind-SelectedItem. - Use the selected item to show details elsewhere on the page.
- Set
ShowPath="false"to hide the path bar.
Search #
The find box matches node labels, opens every branch that leads to a match, and marks the matching cards.
How to use:
Try searching for
How to use:
- Type in the find box. Matching is case-insensitive and uses the
Labeltext. - In a
NodeTemplate, usenode.IsMatchandnode.SearchTextto mark the matching text yourself. - Set
AllowSearch="false"to hide the find box.
Table.
Zoom and pan #
Large maps scroll inside their own frame. Zoom out to see more of the map, and drag the background to move it.
How to use:
Zoom controls are hidden in browsers that do not support the CSS
How to use:
- Use the − and + buttons to zoom between 50% and 150%, and Reset zoom to return to 100%.
- Drag the map background with a mouse or pen to pan. On touch screens, scroll as usual.
- Change the frame's maximum height with the
--bb-mind-map-max-heightCSS variable.
zoom property.
Hide built-in features #
Search, zoom, panning, and the path bar are on by default. Turn off the ones a small map does not need.
How to use:
This map shows only the tree.
How to use:
- Set
AllowSearch,AllowZoom,AllowPan, orShowPathtofalse.
Stack leaves #
In the
How to use:
Turn the switch off to see the classic side-by-side layout.
Down and Up directions, siblings sit side by side, so wide maps grow quickly. Stacking lists leaf children in a column instead.
How to use:
- Set
DirectiontoMindMapDirection.DownorMindMapDirection.Up. - Set
StackLeaves="true". A node whose two or more children are all leaves then lists them in a column.
Dynamic data #
When your data changes, the map shows the new tree. Open and selected items that still exist stay open and selected; removed items leave both bindings.
How to use:
Open or select Build, then remove it to see the bindings update.
How to use:
- Change the children your
Childrenselector returns. - Re-render the page, which happens automatically after a button click.
Large tree #
MindMap keeps all data in memory and stays responsive with hundreds of open nodes.
How to use:
This map lists every Blazor Bootstrap component and its parameters.
How to use:
- Pass the whole tree through
RootandChildren. - Use
InitialExpandDepthto choose how much opens at first, andExpandAllAsync()to open everything.