Mind Map
An idea tree laid out around a central topic, with keyboard editing as in XMind and Miro.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
data | MindMapNode | null | null | The map: one root node { id, label, children?, collapsed?, side?, color?, icon? }. Unknown fields are kept. The
map edits its own copy and fires change with the new object; setting data again replaces the map and clears
the undo history. |
label | string | — | Accessible name of the map. Default: "Mind map". |
layout | MindMapLayout | both | both puts branches on either side of the central topic; left and right put them all on one side. |
editable | boolean | false | Lets the user add, edit, move and delete topics. Navigation, folding and node-click work either way. |
no-drag | boolean | false | Turns off drag to reparent in an editable map, so a drag on a topic pans like a drag on the canvas. |
controls | boolean | false | Draws the zoom toolbar: zoom out, the zoom percent, zoom in and fit. |
minimap | boolean | false | Draws an overview of the map in the corner while it overflows the canvas. |
Events
| Name | Type | Description |
|---|---|---|
change | CustomEvent<MindMapChangeEventDetail> | Fired after an edit, with { data, action }: data is the new map, to save. action is { type, node, parent, index }; type is add, edit, delete, move, collapse, expand, color, paste, undo or redo. |
selection-change | CustomEvent<MindMapNodeEventDetail> | Fired when the user selects another topic, with { node }. Does not bubble: several components fire selection-change, so a listener belongs on the element itself. |
before-change | CustomEvent<MindMapBeforeChangeEventDetail> | Fired before an edit, with { action }. Cancelable: preventDefault() vetoes the edit. |
node-click | CustomEvent<MindMapNodeEventDetail> | Fired when a topic is clicked, or activated with Enter in a read-only map, with { node }. Fired in read-only maps too, to open a topic's details. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
canvas | The c2-pan-zoom the map is drawn in. |
board | The drawing inside the canvas. |
topic | Every topic. |
root | The central topic, in addition to topic. |
main-topic | Each first-level topic, in addition to topic. |
subtopic | Each deeper topic, in addition to topic. |
selected | The selected topic, in addition to topic. |
icon | The icon before a label. |
label | The text of a topic. |
editor | The inline editor. |
toggle | The fold dot, which shows the hidden count while folded. |
add | The round "+" on the selected topic. |
connector | Each connecting curve. |
ghost | The label that follows the pointer while a topic is dragged. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-mind-map--width | length | 100% | Width of the canvas; it is kept even as a flex item, which would otherwise shrink it to nothing. |
--c2-mind-map--height | pixel | 480px | Height of the canvas. |
--c2-mind-map--background | background | #fafafa | The canvas. |
--c2-mind-map--border | border | 1px solid #e4e4e7 | |
--c2-mind-map--border-radius | border-radius | 8px | |
--c2-mind-map--font-family | font-family | inherit | |
--c2-mind-map--transition-duration | duration | 200ms | How long topics take to glide to their new place after an edit. Topics jump under reduced motion. |
--c2-mind-map__grid--display | display | block | none hides the dot grid. |
--c2-mind-map__grid--color | color | #e4e4e7 | |
--c2-mind-map__grid--gap | pixel | 20px | |
--c2-mind-map__branch-1--color | color | #0265dc | The branch colours, taken in turn by the first-level topics. |
--c2-mind-map__branch-2--color | color | #ea580c | |
--c2-mind-map__branch-3--color | color | #0f766e | |
--c2-mind-map__branch-4--color | color | #db2777 | |
--c2-mind-map__branch-5--color | color | #a16207 | |
--c2-mind-map__branch-6--color | color | #7c3aed | |
--c2-mind-map__branch-7--color | color | #0891b2 | |
--c2-mind-map__branch-8--color | color | #52525b | |
--c2-mind-map__root--background | background | #18181b | The central topic's fill. |
--c2-mind-map__root--color | color | #fafafa | |
--c2-mind-map__root--font-size | pixel | 16px | |
--c2-mind-map__root--font-weight | font-weight | 600 | |
--c2-mind-map__root--padding | padding | 10px 18px | |
--c2-mind-map__root--border-radius | border-radius | 8px | |
--c2-mind-map__topic--tint | percentage | 14% | Share of the branch colour in a first-level topic's background. |
--c2-mind-map__topic--background | background | #ffffff | The surface the branch colour is mixed into. |
--c2-mind-map__topic--color | color | #18181b | Text of a first-level topic. |
--c2-mind-map__topic--font-size | pixel | 14px | |
--c2-mind-map__topic--font-weight | font-weight | 500 | |
--c2-mind-map__topic--line-height | line-height | 20px | Line height of every topic but the central one. |
--c2-mind-map__topic--padding | padding | 6px 12px | |
--c2-mind-map__topic--border-width | pixel | 1px | Width of a first-level topic's border, drawn in its branch colour. |
--c2-mind-map__topic--border-radius | border-radius | 6px | |
--c2-mind-map__topic--max-width | pixel | 220px | Longer labels wrap. |
--c2-mind-map__topic__selected--outline | outline | 2px solid #0265dc | |
--c2-mind-map__topic__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | Keyboard focus ring, drawn round the selection outline. |
--c2-mind-map__topic__dragging--opacity | opacity | 0.4 | The topic being dragged, at its old place. |
--c2-mind-map__subtopic--color | color | #18181b | Text of the deeper topics, drawn on a line. |
--c2-mind-map__subtopic--font-size | pixel | 14px | |
--c2-mind-map__subtopic--font-weight | font-weight | 400 | |
--c2-mind-map__subtopic--padding | padding | 4px 2px | |
--c2-mind-map__connector--width | pixel | 2.5px | Width of the first-level connectors. |
--c2-mind-map__connector--taper | pixel | 0.5px | How much thinner each deeper level is. |
--c2-mind-map__connector--min-width | pixel | 1px | |
--c2-mind-map__level--gap | pixel | 56px | Horizontal room between a topic and its subtopics. |
--c2-mind-map__sibling--gap | pixel | 12px | Vertical room between neighbouring subtrees. |
--c2-mind-map__drop-target--background | background | #edf1fe | The topic a dragged topic would land in. |
--c2-mind-map__drop-line--color | color | #0265dc | The dashed line and outline that show where a dragged topic lands. |
--c2-mind-map__ghost--background | background | #ffffff | The label following the pointer during a drag. |
--c2-mind-map__ghost--color | color | #18181b | |
--c2-mind-map__ghost--box-shadow | box-shadow | 0 8px 24px rgba(24, 24, 27, 0.08) | |
--c2-mind-map__toggle--size | pixel | 18px | The fold dot. |
--c2-mind-map__toggle--background | background | #ffffff | |
--c2-mind-map__toggle--color | color | #18181b | |
--c2-mind-map__toggle--font-size | pixel | 12px | |
--c2-mind-map__add--size | pixel | 20px | The round "+" on the selected topic. |
--c2-mind-map__add--background | background | #0265dc | |
--c2-mind-map__add--color | color | #ffffff | |
--c2-mind-map__editor--background | background | #ffffff | |
--c2-mind-map__editor--color | color | #18181b | |
--c2-mind-map__editor--caret-color | color | #0265dc | |
--c2-mind-map__board__focus--outline | outline | 2px solid rgba(2, 101, 220, 0.4) | Focus ring of the canvas, which holds focus after Escape. |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under mind-map, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
label | Mind map | — |
roleDescription | mind map | — |
topicRoleDescription | topic | — |
keyHelp | Tab adds a subtopic, Enter a sibling, F2 edits, Delete removes. Escape, then Tab, leaves the map. | — |
keyHelpReadOnly | Arrow keys follow the drawing, Space folds, Home goes to the central topic. | — |
canvas | Mind map canvas | — |
editTopic | Edit topic | — |
newTopic | New topic | — |
addSubtopic | Add subtopic | — |
fold | Fold | — |
unfold | Unfold {0} hidden topics | {0} count |
ctrlKey | Ctrl | — |
added | Added a subtopic of {0} | {0} parent |
addedSibling | Added a topic next to {0} | {0} sibling |
edited | Renamed to {0} | {0} label |
deleted | Deleted {0} and {1} subtopics. {2}+Z to undo | {0} label {1} count {2} mod |
movedInto | Moved {0} into {1} | {0} label {1} parent |
movedTo | Moved {0} to position {1} of {2} | {0} label {1} position {2} total |
folded | Folded, {0} topics hidden | {0} count |
unfolded | Unfolded, {0} topics shown | {0} count |
recoloured | Changed the colour of {0} | {0} label |
copied | Copied {0} topics | {0} count |
pasted | Pasted {0} topics into {1} | {0} count {1} parent |
undone | Undone | — |
redone | Redone | — |
nothingToUndo | Nothing to undo | — |
nothingToRedo | Nothing to redo | — |
cancelled | Move cancelled | — |