Guide
How to draw maps on any page, in React, with the <orbit-map> element or in a markdown pipeline, and everything a map offers: its options and events, how people move around it, pictures, videos and sounds, editing, export and theming. The map format is the reference for writing maps, and Recipes shows Orbit in each framework.
Drawing a map
import { createOrbitMap } from '@restless-dreams/orbit';
const map = createOrbitMap(document.getElementById('map')!, `# π Project
## Research
## Build
## Launch`);
map.on('focus-change', ({ node }) => console.log('Now looking at', node.text));The map fills its container, so give the container a size. createOrbitMap returns the renderer: call map.render(newMarkdown) to draw a new version (the reader keeps their place), and map.destroy() when you remove it. Options passed in win over the document’s frontmatter; documentToRendererOptions(doc.options) shows what a document asks for. new OrbitSVGRenderer(element, options) plus renderer.render(source) is the same thing in two steps.
React
import { OrbitMindMap } from '@restless-dreams/orbit/react';
const markdown = `# Project
## Research
## Build`;
export const ProjectMap = () => {
return (
<div style={{ height: 480 }}>
<OrbitMindMap source={markdown} onNodeClick={(node) => console.log(node.text)} />
</div>
);
};OrbitMindMap fills its parent, so give the parent a size. Pass the map as source (markdown or YAML), as a parsed document, or as a node tree in data. Inline callbacks and inline theme / palette objects are fine: the map only redraws when their values change.
- Drive it from code with a ref:
ref.current.flyTo(id),overview(),setViewMode(mode),zoomBy(factor),fit(), andref.current.rendererfor everything else. - Control the focus with
focusedIdandonFocusChange, like a controlled input. - Server rendering: the component is marked
"use client"for React Server Components. On the server and in the first render it draws a static SVG of the map, so the page shows it before JavaScript runs; the live map replaces it on mount (staticFallback={false}turns that off).
Web component
import { defineOrbitMapElement } from '@restless-dreams/orbit';
defineOrbitMapElement();<orbit-map height="420" view="focus">
# π Project
## Research <!-- orbit status: active -->
## Build
</orbit-map>Indent the content however you like, and <!-- orbit β¦ --> comments and frontmatter work inside the element. The map renders in a shadow root, so the raw markdown is never shown. You can also put the source in a <script type="text/orbit"> child or a source attribute.
- Size: the element is a block, 420 px tall by default. Use the
heightattribute,heightin the frontmatter, or plain CSS (orbit-map { height: 60vh }, which wins over both). - Attributes:
view,theme,palette(comma-separated),max-depth,interactive,animation,editable,editing-keys. Changing one updates the map in place. - Updates: editing the element’s content or its
sourceproperty redraws the map, and the reader keeps their place.element.flyTo(id)andelement.overview()move the map,element.openMedia(id)shows a node’s picture or plays its video or sound (see Pictures and videos), andelement.rendereris the underlyingOrbitSVGRenderer. - Events: the map’s events bubble out of the element (see Events below).
- Errors: a map that can’t be drawn shows an error card with the line number and fires an
orbit-errorevent (event.detail.message,.line,.error, the error itself ornull, and.diagnostics).
To avoid a flash of raw markdown before the script loads, hide undefined elements: orbit-map:not(:defined) { visibility: hidden; }.
Markdown pipelines (marked)
import { Marked } from 'marked';
import { orbitMarked, hydrateOrbitBlocks } from '@restless-dreams/orbit/marked';
const markdown = new Marked(orbitMarked());
container.innerHTML = await markdown.parse(article); // orbit fences become map placeholders
hydrateOrbitBlocks(container); // turns them into live mapsFences can carry display options: ```orbit height=480 theme=glass view=all. Each map fills its placeholder, which is 420 px tall unless the fence’s height or the map’s frontmatter says otherwise; CSS that gives the placeholder a height wins over both. Until a placeholder hydrates (or when JavaScript is off), it contains a nested list of the map, so the content stays readable and indexable. renderOrbitMarkdown(markdown) renders with a private instance in one call; configureMarked(instance) registers the extension on an existing instance (the global marked by default). Neither touches the global marked unless you pass it.
Format
Orbit reads two flavors: orbit-md, its markdown, and YAML. The dispatcher (parseOrbit) tells them apart. The map format has every rule, attribute, option and diagnostic; npx @restless-dreams/orbit example prints a map that uses all of them.
orbit-md, the markdown flavor (recommended for maps people write)
Every heading and every list item is a node; everything else belongs to the node above it. Headers (#β######, or lines underlined with === and ---) nest by level, and every list under a heading is its children, as deep as you indent. Checkboxes set a status: - [ ] Draft is todo, - [x] Ship is done, - [/] Build is active. Hashtags at the end of a title are tags: - Offline sync #frontend.
A document can also be just a list. A single top item becomes the root; with several, the root is named after the frontmatter title, a one-line paragraph above the list, or “Untitled map”. Several # headings share a root the same way:
Project plan
- Research
- Build
- Launch# π Project Launch
## Research
- Market analysis
- User interviews
## Build
### Frontend
### Backend
## LaunchImage, video, and embed:
## Mountain Trip

We left at 5am to catch the sunrise.Text under a heading or a list item is its note: paragraphs, quotes, code. The
list after it is still the children. Under a list item, indent the note, a
picture or an attribute block, as you would under a heading. To keep a bullet
list inside a note, quote it with >:
## Build
Currently focused on the frontend. Starts when [Research](#research) is done.
- Frontend <!-- orbit status: active -->
Vite + React. Ships behind the beta flag.
- Backend

> - Billing
> - Search
## ResearchA #id link, like [Research](#research) above, flies to that node of the map.
Per-node attributes go in HTML comments that start with orbit. Other comments are hidden, as markdown hides them:
## Build
<!-- orbit
color: "#F5A3A8"
status: active
priority: 1
tags: [frontend, sprint-3]
-->Document-level frontmatter sets renderer options:
---
view: focus
palette: ["#F8D978", "#F5A3A8", "#A8DDB5"]
baseUrl: /docs/assets/
---
# ProjectYAML flavor (for app-generated maps)
title: My Project
view: focus
nodes:
- text: Project
icon: π
children:
- text: Research
tags: [discovery]
children: [Market analysis, User interviews] # scalar shorthand
- text: Build
status: active
note: |
Currently focused on the frontend.
Targeting end-of-quarter ship.Plain strings in children are shorthand for { text: ... } leaf nodes.
Document options
Frontmatter (markdown) or top-level keys (YAML): title (used as the SVG’s
accessible label), view, theme, showRings, interactive, animation,
speed, palette, height, maxDepth (levels below the root to render;
1 = root + direct children), className, baseUrl, schemaVersion (the
format version the document is written for, 1). Keys Orbit doesn’t know are
kept and written back, and saving keeps a file as it was written: only the
ideas an edit changed are written again (see
What saving keeps).
Problems in a document
Parsing is forgiving. When something is wrong but recoverable (an unknown frontmatter key, a second # root, an attribute block that isn’t valid YAML, an image without a URL), the parser works around it and records a diagnostic with a code, the line it’s on and a message that says how to fix it (Unknown frontmatter key "rings" (ignored). Did you mean "showRings"?):
const doc = parseOrbit(source);
for (const problem of doc.diagnostics ?? []) {
console.log(problem.line, problem.code, problem.message);
}Pass { strict: true } to throw an OrbitParseError (with code and line) on the first problem instead. orbit validate lists every problem and fails until there are none. When a map rendered through <orbit-map> or hydrateOrbitBlocks can’t be drawn at all, it shows an error card and dispatches an orbit-error event; the other maps on the page still render.
Round-tripping
serializeOrbitMarkdown / serializeOrbitYAML produce documents that parse back to the same tree. The markdown reads the way people write maps:
- Headings and lists: the root and its children are headings, and everything below them is a nested list.
- Titles: statuses on list items are checkboxes (
[ ],[/],[x]) and simple tags are hashtags; titles are escaped only where markdown would misread them. - Attributes: short ones go on the node’s line,
<!-- orbit color: "#E8A33D", priority: 2 -->: up to three, or more while the comment stays under 80 characters (<!-- orbit type: goal, target: 5, current: 2, unit: apples -->). The rest go in a comment block below it. - Notes and media: notes are plain paragraphs, quoted only when their lines would read as nodes, pictures and videos are lines of their own, and sounds are attributes.
A map written in that style comes back unchanged.
import { parseOrbit, serializeOrbitMarkdown, serializeOrbitYAML } from '@restless-dreams/orbit';
const doc = parseOrbit(source);
const asYaml = serializeOrbitYAML(doc);
const backToMarkdown = serializeOrbitMarkdown(parseOrbit(asYaml));Action API
Wire your own behavior on click:
const renderer = new OrbitSVGRenderer(host, {
onAction: ({ node, action }) => {
if (action === 'image') {
openMyLightbox(node.image!.src);
}
if (action === 'note') {
openMyDrawer(node.note!);
}
return false; // skip Orbit's own viewer and detail sheet
},
});The focused node shows a button for each kind of content it has, then your own actions. They sit under it, or, where its planets crowd it (as they do on a phone), under the whole orbit, which is then fitted to leave them room: they never cover a planet. When onAction isn’t provided (or doesn’t return false), “View picture”, “Play video” and “Play sound” open the media viewer, and the other buttons the built-in detail sheet: a panel along the right edge on wide screens and a bottom sheet on phones (swipe down to close), with the node’s media, note, files, status and tags, and arrows to step through its siblings. YouTube and Vimeo links play through their embeddable players (youtube-nocookie.com/embed/β¦, player.vimeo.com/video/β¦). Links open in a new tab.
Notes are markdown and are rendered safely (no raw HTML). Opt-out flags: showActionButtons: false, showDetailSheet: false and showMediaViewer: false. Custom note rendering: noteRenderer: (note, ctx) => '<p>...</p>'. The HTML it returns is used as is, so sanitize it if the note content is untrusted.
Pictures and videos
“View picture”, “Play video” and “Play sound” open the media viewer, over the whole window, even when the map sits in a small box. It follows the map’s theme, light or dark.
- Pictures fit the window. The wheel, a pinch, a double click or tap, the
+,βand0keys and the zoom buttons zoom around the point under the pointer, and a zoomed picture pans with a drag. - Live photos, pictures with the few seconds of video a phone records around them, play that motion over the picture: once as the viewer shows them, muted, and again, with their sound, while the picture, its “Live” mark or the space bar is held. With reduced motion, only when asked.
- Videos start at once: files in the browser’s own player, YouTube and Vimeo in theirs.
- Sounds start at once too, in Orbit’s own player, under the node’s picture or art made of its color and icon: where the sound is, to drag, ten seconds back and on, and its sound off and on.
- Every picture, video and sound of the map, in reading order: the previous and next buttons, the arrow keys or a swipe step through them, and a counter says where you are.
- Around them, the node’s title, the caption and the picture’s description, with a link to the picture, the video’s page or the sound. Esc, a click around the media or a swipe down closes the viewer, and focus goes back where it was.
The detail sheet’s picture opens the viewer too, its video and sound have a button that moves them there, and its sound plays right there, in a player on one line. showMediaViewer: false keeps pictures, videos and sounds in the detail sheet, and onAction returning false (or the action event’s preventDefault()) skips both, as for any button.
A page can drive the viewer itself, to show a picture big or play a video or a sound on a screen of its own, such as an audience’s while someone presents:
map.openMedia('summit'); // a node's picture, or its video, or its sound
map.openMedia('trail', { kind: 'video', autoplay: false }); // its video, ready to play
map.openMedia('trail', { kind: 'video', startAt: 42 }); // its video, playing from 0:42
map.openMedia('kickoff', { kind: 'audio' }); // its sound, playing
map.playMedia();
map.seekMedia(42);
map.pauseMedia();
map.unmuteMedia(); // from a press, for a video a browser started muted
map.closeMedia();
map.on('media-state', ({ node, playing, time }) => tellThePresenter(node.id, playing, time));openMedia works whatever showMediaViewer and showDetailSheet say. On a map that isn’t interactive, the viewer is the page’s to drive: no buttons, no video controls, and no input of its own. Pictures, videos and sounds covers the keys, YouTube and Vimeo, sound and autoplay, and the events.
Files
An idea can hold files: a PDF, a spreadsheet, a ticket, any file (files, see Map format). Its planet wears a paperclip at its upper left, with how many from two on, and its description says so (“has 2 files”). In focus, it offers “Show files”, which opens the detail sheet at them: a row for each, with its kind’s icon, its name, and its kind and size under it (“PDF Β· 48 kB”).
A file pressed there opens its address in a new tab, resolved against baseUrl, as a link does: only an address on the web or relative to the map ever opens. An app that keeps the files itself, as one on a phone does, takes the press with onFileOpen returning false or the file-open event’s preventDefault(), and opens the file its own way:
map.on('file-open', (event) => {
event.preventDefault();
openInAnotherApp(event.node.id, event.file.src, event.file.type);
});Where the files can’t be opened from, as in a web page made without them, openFiles: false lists them without opening them, and the sheet says they stayed with the map. exportWebPage makes its pages so. Prints and PDFs (renderPrintLayout) name each file, its kind and its size.
Extending
Give nodes a type, add your own buttons, name your own themes and status words. Pass them to one map, or register them once for every map, <orbit-map> elements and markdown pages included:
import { createOrbitMap, registerTheme } from '@restless-dreams/orbit';
registerTheme('brand', { preset: 'night', tokens: { 'color-root': '#FFD166' } });
createOrbitMap(element, '# Launch\n## v1.0 beta <!-- orbit type: milestone, status: review -->', {
theme: 'brand',
nodeTypes: {
milestone: { label: 'Milestone', icon: 'π', color: '#F59E0B', details: (node, element) => { element.textContent = 'Due Friday'; } },
},
actions: [{ id: 'assign', label: 'Assign', icon: 'π€', run: (node) => openAssignDialog(node) }],
statuses: { review: 'active' },
});A node type sets its nodes’ icon, color and theme tokens, can draw inside them (render), add a section to the detail sheet (details) and bring its own actions. nodeTypeFor gives nodes that name no type one to be drawn as, for display only: it’s never written to the map. Extending covers every option.
Editing on the map
Let people build a map on the map itself. With editable, a + in the orbit adds an idea, typed right inside its new planet. Enter adds it and opens the next one, so ideas go in one after another. A long press, a right click or F2 edits a node’s text where it is, and a node held still lifts, to be dragged onto another node or to a new place in the orbit:
const map = createOrbitMap(element, markdown, {
editable: true,
onEdit: () => save(map.toMarkdown()),
});With editingKeys too, the keyboard builds maps as in mind-map apps: Tab adds an idea under the node with keyboard focus, Shift+Enter beside it, and Delete removes it; while typing, Tab and Shift+Tab go a level down and up.
For a menu of your own, onNodeContext reports the long press or right click and where it happened, and onNodeDrag when the press moves on to drag the node, the moment to close the menu. editNode(id) and editNewNode(parentId, index?) open the field to type in (stopEditing() closes it), and addNode, updateNode, removeNode and moveNode change the map, animating each edit and firing edit. toMarkdown() writes the edited map as orbit-md, and getDocument() gives it as a document. For text or files dragged onto the map from elsewhere, getNodeAt(x, y) finds the node under them and setDropTarget(id) lights it up. Editing covers menus, dragging, drops, keys, ids, focus, saving, React and <orbit-map editable>.
Hiding ideas to reveal later
hideChildren(ids) hides the ideas under nodes, and revealChildren(ids?) shows them again: the cards of a quiz, where you recall what’s under an idea before you see it, or a talk that keeps each step’s ideas for when it gets there.
const map = createOrbitMap(element, markdown);
map.hideChildren(['verbs', 'nouns']);
map.flyTo('verbs');
// β¦and when the reader is ready:
map.revealChildren('verbs');A node in focus keeps a faint place in its orbit for each hidden idea, in that idea’s color and where it will land, so the reader knows how many there are. Revealing them grows each one out of the node to its place, with the same motion as flights, and each place fades as its idea lands on it. Anywhere else, a node with hidden ideas shows as if folded, with a “+N” and no moons, and the overview and the outline leave them out. Screen readers hear how many ideas are hidden, on the node (“Ser, 3 hidden ideas”) and as the map moves to it, and then their names as they show.
Hiding is only how the map looks: the map, toMarkdown() and its events don’t change, and nothing is edited. Ids the map doesn’t have, and nodes with no ideas under them, are left out. A node keeps its ideas hidden when an edit renames it, and new text for the map keeps the nodes it still has hidden. With no ids, revealChildren() shows every hidden idea. Both return whether anything changed, and <orbit-map> and the React wrapper’s ref have them too.
Bringing a node up close
spotlight(id, options?) brings a node up close, for something of your own to lie over it: a surface to draw on, say, or a picture to frame. The camera flies until the node fills most of the map, the rest of the map dims under the sheet’s backdrop, and the node’s name, icon, badges and its type’s content step aside, leaving its color and its picture. endSpotlight() flies the camera back where it was, and the map brightens again.
const map = createOrbitMap(element, markdown, { editable: true });
map.on('spotlight', ({ phase, x, y, radius }) => {
if (phase === 'rest') {
canvas.style.cssText = `left: ${x - radius}px; top: ${y - radius}px; width: ${radius * 2}px; height: ${radius * 2}px`;
canvas.hidden = false;
}
});
map.spotlight('summit', { share: 0.8, insets: { bottom: 96 } }); // 80% of the room above a 96 px toolbar
// β¦and when the drawing is done:
canvas.hidden = true;
map.updateNode('summit', { image: { src: drawing } });
map.endSpotlight();share is how much of the room the node fills across, along the room’s shorter side (0.86 by default), and insets the room your own controls take while it’s up close, as the insets option says for the map; the node is held in the middle of what’s left. The map’s own insets stay as they are.
The spotlight event says where the node’s circle is, in px from the map’s top left: on each frame of the flight to it (move), once it lands (rest), and once the flight back lands (end). While the node is up close the map takes no gestures, keys or presses, the orbit doesn’t drift, and the camera holds the node where it landed, whatever changes under it: an edit to the node, a new picture included, keeps its circle where it is, and a map that changes size fits it again and says where it rests now (rest again). A node that leaves the view, as an edit removes it, is let go of, and so is one when flyTo, overview or setViewMode take the map somewhere else. Bringing another node up close flies there, and endSpotlight() still flies back where the camera was before the first. With reduced motion, the camera moves at once, and the map dims with a fade.
spotlight returns false when the current view doesn’t draw the node. getNodeCircle(id) says where any node is drawn on screen now, or null. <orbit-map> and the React wrapper’s ref have all three.
What follows the view leaves hidden ideas out: the map, the outline, the media viewer’s steps through the map’s pictures, videos and sounds, and toSVGString(), which exports the view with the faint places. A node whose ideas are hidden has no + to add one either, and editNewNode returns false there: reveal them first. What reads the map itself reads every idea: toMarkdown(), renderToSVGString, prints (a map’s web page and renderPrintLayout) and map tools, so a language model reading the map sees the hidden ideas too.
Interaction
A map has two views. Focus puts one node at the center (the sun) with its children around it (planets) and their children as small moons. The overview lays out the whole tree.
- Moving around: click or tap a planet (or a moon) to fly into it; click the sun, the back chip or a breadcrumb to go back up. The camera flies between views along a smooth zoom path, and nodes that both views share move into place.
- Zooming: the wheel, a trackpad pinch or a two-finger pinch zooms around the pointer. In focus mode, zooming into a planet enters it once it’s big enough to read, so a crowded orbit can be zoomed into and read first; zooming out leaves the current node, and a small zoom out springs back. The overview zooms and pans freely, with momentum.
- Spinning: drag around the sun to turn the orbit. A hard flick keeps it spinning and slowing down like a fidget spinner; a touch catches it.
spin: { snap: 'planet' }brings the nearest planet to the top as it stops, andonSpinSettletells you which one. - Pages that scroll: when the page around the map scrolls, the wheel scrolls the page and Ctrl (β on a Mac) + wheel zooms the map; on touch screens, one finger scrolls the page except on the orbit itself.
zoom: { wheel: 'always' }or'modifier'changes this. - Keyboard: the map is one tab stop. In focus mode,
β/βstep through the planets (turning the orbit so the chosen one is on top),βenters the orbit,βreturns to the sun,Enter/Spaceflies into a node,Escape/Backspacegoes back. In the overview, the arrow keys follow the tree.+,βand0zoom and fit. - Assistive technology: the list button shows the whole map as a nested list, which screen readers can also browse at any time, and moves are announced. When the reader asks for reduced motion, views cross-fade instead of flying and a flicked orbit doesn’t coast.
- Pictures, videos and sounds: “View picture”, “Play video” and “Play sound” open them over the whole window, to zoom into a picture (the wheel, a pinch, a double click or tap) and to play a video or a sound; the arrows and swipes step through every picture, video and sound of the map. See Pictures and videos.
- Editing: on
editablemaps, the + in the orbit adds an idea and a long press, a right click or F2 edits a node’s text. A long press, a right click, or the context menu key (or Shift+F10) also firesnode-context, for a menu of your own. A node held still lifts: drag it onto another node to move it there, or along the orbit to a new place. WitheditingKeys, Tab, Shift+Enter and Delete add and remove ideas from the keyboard. See Editing on the map. - Programmatic:
renderer.setOptions(options)changes the options it’s given, such as the theme or the language, and keeps the others (see Theming and Languages);renderer.getSVGElement()is the map’s<svg>.renderer.flyTo(id)(in focus mode),renderer.overview(),renderer.focusNode(id)(keeps the current view),renderer.setViewMode(mode),renderer.zoomBy(factor),renderer.fit(),renderer.spin(degreesPerSecond),renderer.getFocusPath(),renderer.getFocusedNode(),renderer.getViewMode(),renderer.getNodeColor(id)for the color a node is drawn with, to match a list or legend beside the map,renderer.getNodeAt(x, y)andrenderer.setDropTarget(id)for drops from elsewhere (see Drops from elsewhere),renderer.hideChildren(ids)andrenderer.revealChildren(ids?)to keep ideas for later (see Hiding ideas to reveal later),renderer.spotlight(id, options?),renderer.endSpotlight()andrenderer.getNodeCircle(id)for something of your own over a node (see Bringing a node up close), andrenderer.openMedia(id),closeMedia(),playMedia(),pauseMedia(),seekMedia(seconds)andunmuteMedia()for the media viewer.
Events
Listen on the renderer, or for DOM events that bubble from the map’s container (and out of <orbit-map>):
const stop = map.on('focus-change', ({ node, path }) => {});
element.addEventListener('orbit-focus-change', (event) => event.detail.node);| Event | DOM event | Detail |
|---|---|---|
focus-change |
orbit-focus-change |
{ node, path }: the focused node and the path from the root |
view-mode-change |
orbit-view-mode-change |
{ mode }: 'focus' or 'all' |
node-click |
orbit-node-click |
{ node }, before the map reacts |
action |
orbit-action |
{ node, action, sourceEvent }; preventDefault() skips the built-in viewer, sheet or link |
spin-settle |
orbit-spin-settle |
{ node }: the planet on top when a spun orbit stops (planet, its old name, until 1.0) |
node-context |
orbit-node-context |
{ node, x, y }: a long press, right click or context menu key on a node, and where; preventDefault() takes the press |
edit |
orbit-edit |
{ kind, node, tree }: an edit, made on the map or with addNode, updateNode, removeNode or moveNode |
editor-open, editor-close |
orbit-editor-open, orbit-editor-close |
{ node, parent }: the field for typing on the map opened or closed, on node or for a new idea under parent |
node-drag |
orbit-node-drag |
{ phase, node, parent, index }: a node dragged somewhere else, as it leaves its place (start), when where it would go changes (over), and when it’s let go (end) |
media-open, media-close |
orbit-media-open, orbit-media-close |
{ node, kind, index, total }: the media viewer opened (or stepped) on a node’s picture (kind: 'image'), video ('video') or sound ('audio'), index of total in reading order, or closed |
media-state |
orbit-media-state |
{ node, kind, playing, time, duration, ended, muted }: the viewer’s video, sound or live photo’s motion (kind: video, audio or image) started, paused, moved on, ended or was muted; while it plays, its time a few times a second |
file-open |
orbit-file-open |
{ node, file, index, sourceEvent }: one of a node’s files was opened in the detail sheet; preventDefault() keeps it from opening in a new tab, for an app to open it its way |
spotlight |
orbit-spotlight |
{ phase, node, x, y, radius }: where a node spotlight brought up close is on screen, its circle’s center and radius in px, as the camera flies to it or back (move), once it rests there and whenever it rests somewhere else (rest), and once it’s back in its place (end) |
orbit-error |
{ message, line, error, diagnostics }, on elements whose map couldn’t be drawn |
The on⦠options hear the same, a few in a shape of their own:
| Option | Called with |
|---|---|
onFocusChange |
(node, path) |
onViewModeChange |
(mode) |
onNodeClick |
(node) |
onAction |
({ node, action, sourceEvent }); returning false skips the built-in viewer, sheet or link, and the action event with it |
onFileOpen |
({ node, file, index, sourceEvent }); returning false keeps the file from opening in a new tab, and skips the file-open event with it |
onSpinSettle |
(node) |
onNodeContext, onEdit, onEditorOpen, onEditorClose, onNodeDrag, onMediaOpen, onMediaClose, onMediaState, onSpotlight |
the event’s detail |
A callback that throws doesn’t stop the map, as a listener that throws doesn’t: the error is reported (reportError, or thrown on its own afterwards), and the event still reaches the on() listeners and the DOM.
Server rendering and export
renderToSVGString draws a map without a browser, for static sites, emails, docs and print. Colors are resolved to plain values and labels are SVG text, so the file looks the same anywhere:
import { renderToSVGString } from '@restless-dreams/orbit';
const svg = renderToSVGString(markdown, { width: 1200, height: 800, theme: 'night', view: 'all' });Options: width and height (positive, up to a million pixels), view, focus (a node id), theme, palette, maxDepth, showRings, title, baseUrl, responsive (100 % wide and tall instead of pixels), idPrefix (without one, the SVG’s ids are made from the drawing, so SVGs of different maps can share a page), language and strings for the drawing’s few words (an untitled idea, the empty map), and nodeTypes, statuses and nodeTypeFor, as the renderer takes them (see Extending). In the browser, renderer.toSVGString() exports what’s on screen, ideas hidden for later included: they stay hidden, and their places show as on the map. renderToSVGString has no view to follow, so it draws every idea.
A map as a web page
orbit export --html makes one HTML file with Orbit, the map and its pictures inside. It opens in any browser, offline: explore the map with Orbit’s own controls, or present it, one idea at a time in reading order with its note as a caption (the Present button or P; the arrows, Space or a swipe step, Escape stops). It’s the way to share a map for review: send the file to someone, or to your own phone.
npx @restless-dreams/orbit export --html map.md --out map.html --theme autoPictures and sounds on your computer that the map shows (its nodes’ pictures, their live photos’ motions and their sounds, videos’ thumbnails and pictures in notes) go inside the page; pictures and sounds on the web stay links, and so do videos. --title, --theme, --view, --focus and --language work as for render; with --theme auto the page follows the reader’s light or dark mode.
In code, exportWebPage returns the same page. It needs Orbit’s web page script, @restless-dreams/orbit/web-page.js, as text, to put inside:
import { readFileSync } from 'node:fs';
import { exportWebPage } from '@restless-dreams/orbit';
const script = readFileSync(new URL(import.meta.resolve('@restless-dreams/orbit/web-page.js')), 'utf8');
const html = exportWebPage(markdown, { script, theme: 'night', media: { 'photos/summit.jpg': 'data:image/jpeg;base64,β¦' } });Options: title, theme, view, focus, language, strings and media, the pictures and sounds to put inside the page by the address the map gives them (data:audio/mp4;base64,β¦ for a sound, data:video/mp4;base64,β¦ for a live photo’s motion).
Printing and PDF
A map’s web page prints laid out for paper, so the browser’s Print, or Save as PDF, gives a document to email, hand in or print: the title, the map as a picture the width of the page, then every idea in reading order with its status, tags, priority, link (its address printed, and still a link in a PDF), note, picture, video and sound (by its caption, with its address when it’s on the web). An idea never breaks across pages, a heading stays with what follows it, and the map prints on a light theme (Printing).
renderPrintLayout lays a map out that way in any page. It reads the map itself, so it prints every idea, ideas a map on screen hides for later included. It fills an element, which you show only in print:
import { renderPrintLayout } from '@restless-dreams/orbit';
renderPrintLayout(document.querySelector('#print'), markdown, { view: 'all', language: 'es' });#print { display: none; }
@media print {
#app { display: none; }
#print { display: block; }
}Options: title, picture (false leaves the map’s picture out), view and focus (what the picture shows), theme, palette, language, strings, baseUrl, nodeTypes, statuses, nodeTypeFor (a node type’s label, icon and details print with its nodes) and idPrefix. A headless browser makes the PDF without anyone printing: chromium --headless --no-pdf-header-footer --print-to-pdf=map.pdf map.html, or Playwright’s page.pdf().
Map tools for AI
createMapTools gives a language model tools to read a map and change it: read it as an outline with each node’s id, search it, add branches written as markdown, rename, mark, move, sort and remove nodes. tools.for('anthropic'), 'openai', 'openai-chat' or 'gemini' lists them in the shape that provider’s API takes, tools.definitions as MCP lists tools, and tools.run(name, input) carries out each call. On a map on screen, each change animates and fires edit; on a document, it changes the document in place. A call a model gets wrong changes nothing, and its result says what to send instead. Map tools for AI has the loop for each provider.
Notes in your own UI
renderNoteMarkdown renders a note the way the detail sheet does, for a page that shows notes itself, such as captions under a presented map. It builds DOM nodes rather than HTML text, so a note can’t add markup, and its links and pictures go through the same URL guard as the map:
import { renderNoteMarkdown } from '@restless-dreams/orbit';
caption.replaceChildren(renderNoteMarkdown(node.note ?? '', { baseUrl }));Options: baseUrl, where relative links and pictures resolve from, resolveLink(href), whether a #id link points at a node of the map (links to missing nodes show as plain text), and onCheck.
A note’s checklists show as checkboxes, which change only with onCheck: it’s called when someone checks or unchecks one, with the box’s line in the note (from 0) and whether it’s checked now. setNoteCheckbox(note, line, checked) gives the note with that one box changed and every other character as it was, or null when the note has no box on that line, as after it changed. Save it with updateNode, as the detail sheet does on an editable map: it’s an edit like any other, and saving changes just that line of the file.
import { findNodeById, renderNoteMarkdown, setNoteCheckbox } from '@restless-dreams/orbit';
const showNote = (id) => {
const note = findNodeById(map.getDocument().root, id)?.note ?? '';
caption.replaceChildren(renderNoteMarkdown(note, {
onCheck: ({ line, checked }) => {
const changed = setNoteCheckbox(findNodeById(map.getDocument().root, id)?.note ?? '', line, checked);
if (changed === null) {
showNote(id); // The note changed since it showed: show it as it is.
} else {
map.updateNode(id, { note: changed });
}
},
}));
};Renderer options
| Option | Default | |
|---|---|---|
view |
'focus' |
'focus' or 'all' (the overview). |
focus |
the root | The node in focus when the map first draws, by id: to open a map where the reader left it. |
theme |
'paper' |
A theme name (see Theming) or { preset, tokens }. |
palette |
theme colors | Node colors: the first for the root, the rest cycle through the branches. |
maxDepth |
all levels | Levels below the root to draw. |
showRings |
true |
Dashed orbit rings. |
interactive |
true |
false draws a still picture. |
showControls |
true |
Breadcrumbs, view switch, list button and zoom buttons. |
showActionButtons / showDetailSheet |
true |
Content buttons under the focused node / the built-in detail sheet. |
showMediaViewer |
true |
Pictures, videos and sounds open in the media viewer, over the whole window; false keeps them in the detail sheet. |
openFiles |
true |
The detail sheet’s files open, each in a new tab unless onFileOpen or the file-open event takes it; false lists them without opening them, and says they stayed with the map, as a web page made without them does. |
editable |
false |
A + in the orbit to add ideas, text edited inside nodes (long press, right click or F2), and nodes dragged somewhere else. |
editingKeys |
false |
Mind-map keys on editable maps: Tab adds an idea under a node, Shift+Enter beside it, and Delete removes it; while typing, Tab and Shift+Tab go a level down and up. |
longPressDelay |
500 |
Milliseconds a touch holds still on a node before it is a long press; apps can pass their platform’s own. |
insets |
{ top, right, bottom, left } in px: the parts of the map your page covers with its own controls, such as a floating toolbar. Views are fitted into what’s left, and the map still draws under them. |
|
insetsTransition |
'instant' |
How the insets a setOptions call brings take effect, for that call alone. By default a fitted view is kept within its new room at once, as it must be while a keyboard slides or a sheet is dragged and the insets change every frame. 'glide' glides it all the way from where it was, with the camera, for a change made once, such as a panel coming or going. |
animation / speed |
false / 90 |
Let the orbit drift slowly, one turn every speed seconds; it pauses while you point at it, tab through it, zoom or pan. |
spin |
{ decay: 1.4, maxSpeed: 1440, snap: false, haptics: false }: seconds for a flick to lose two thirds of its speed, fastest spin in degrees per second, snapping a planet to the top, and a light vibration as planets pass the top. |
|
zoom |
{ wheel: 'auto', minimum: 0.4, maximum: 6 }: wheel behavior and the zoom range relative to the fitted view. minimum is the overview’s: focus mode goes up a level as you zoom out, and stops at 0.6. |
|
transitionDuration |
'auto' |
Flight length in milliseconds, scaled to the distance travelled when 'auto'; 0 turns flights off. |
ariaLabel |
document title | The map’s accessible name, which screen readers say and nothing shows. It isn’t called title, as the document’s key and the exports’ option are, because those can show: a document’s title names its root when it has no single top heading, and a page’s is its heading. In HTML, title is a tooltip. |
language |
the page’s | The language of the map’s buttons, sheets and announcements: a tag like 'es' (Languages). By default, the closest lang attribute around the map. |
strings |
Words to change on this map only: { zoomIn: 'Closer' }. |
|
baseUrl |
Resolves relative image, video, sound and link URLs: an http, https or file address, or a relative one. Joined to a base of any other kind, such as javascript:, they stay relative. |
|
onNodeClick, onFocusChange, onViewModeChange, onAction, onSpinSettle, onNodeContext, onEdit, onEditorOpen, onEditorClose, onNodeDrag, onMediaOpen, onMediaClose, onMediaState, onFileOpen, onSpotlight |
Callbacks (see Events). | |
noteRenderer |
Renders note markdown to HTML yourself. | |
nodeTypes, actions, statuses, nodeTypeFor |
Node types, buttons of your own, status words, and the type a node that names none is drawn as (see Extending). |
CLI
npx @restless-dreams/orbit validate my-map.md # every problem as my-map.md:line: severity: message [code]
npx @restless-dreams/orbit validate --json my-map.md # the same as JSON, for scripts and coding agents
npx @restless-dreams/orbit validate --tree my-map.md # the map as Orbit reads it, a node a line with its #id
npx @restless-dreams/orbit render my-map.md --out my-map.svg # draw a map to SVG (--theme, --view, --focus, --width, --height, --language)
npx @restless-dreams/orbit convert --to yaml my-map.md # markdown β YAML (either direction)
npx @restless-dreams/orbit convert --to md Plan.xmind --out plan.md # a map from XMind, FreeMind, Freeplane or OPML; --to opml writes OPML
npx @restless-dreams/orbit example > my-map.md # a map with the main features (--yaml for YAML)
npx @restless-dreams/orbit --version # the installed versionUse - as the file to read from stdin, and --help after any command for its options. validate exits with 1 while the map has a problem (--loose accepts the ones the map works around, but never a map it can’t read); every command exits with 2 for a mistake in the command itself. render, export and convert go on after warnings, but a map with an error (one Orbit couldn’t read past, or written for a newer version of the format) is never written: they exit with 1 and write nothing, so convert --out map.yaml map.yaml can’t put an empty map where yours was. render links pictures on your computer from where the SVG goes, so it can move with them. convert reads other apps’ maps as Maps from other apps says, and writes --out’s pictures next to the map. The command itself is orbit: where the package is installed, scripts can call orbit validate my-map.md directly.
Languages
Maps speak the language of the page they’re on: the buttons, the detail sheet, the media viewer and everything screen readers hear. English, Spanish and Brazilian Portuguese are built in; registerLanguage adds others, and the language and strings options pick a language or change single words for one map.
import { createOrbitMap, registerLanguage } from '@restless-dreams/orbit';
createOrbitMap(element, markdown, { language: 'es' }); // or <html lang="es">, or <orbit-map lang="es">
registerLanguage('fr', { zoomIn: 'Zoomer', overview: 'Vue dβensemble' });Languages lists every word, and how to translate them.
Theming
Pick a theme with the theme option, the theme attribute or theme: in the frontmatter:

paper(the default): pastel planets with soft shadows, on your page’s own background.night: planets that glow on a deep navy sky.glassandglass-night: frosted, translucent planets over a soft backdrop of their own.cosmos: jewel-toned planets around a golden star, in a field of stars.blueprint: outlined planets, construction lines and monospaced labels on a gridded blue sheet.ink: black line art with serif lettering, on your page’s own background.contrast: black outlines, solid colors and bold labels, for the most legible map.flatandflat-night: solid, saturated planets with no shading, shadows or glow.materialandmaterial-night: Material 3’s tonal containers and surfaces.materialTheme('#0B57D0')builds the same look from any color, the way Material You colors an app from its wallpaper.liquidandliquid-night: liquid glass, clear planets that catch the light along their rims, over a vivid wallpaper of their own.auto:paperornight, following the reader’s light or dark preference.
Labels keep at least 4.5:1 contrast with their node in every theme.
Every color, size and finish is a CSS custom property, so you can restyle a map from your own stylesheet (the full list). Properties set by the page win over the theme:
orbit-map,
.my-map {
--orbit-sans-font: Inter, sans-serif; /* your font, in every sans-serif theme */
--orbit-surface: #fbf8f3; /* background behind the map */
--orbit-color-root: #f8d978; /* the root, then one color per branch */
--orbit-color-1: #f5a3a8;
--orbit-color-2: #a8ddb5;
--orbit-node-text: #243042;
--orbit-node-shadow-opacity: 0; /* planets without a shadow */
--orbit-ring-dash: none; /* solid orbits */
--orbit-sheet-background: #ffffff; /* the detail sheet and the media viewer */
--orbit-focus-ring: #2563eb;
}Names are measured in the font they’re drawn with, so they fill their nodes without spilling out of them, in any font, and fit again when a web font arrives (Fonts).
The full list is exported as THEME_TOKENS, and themeTokens(name) returns a theme’s values (for example to style your own UI to match). A theme object sets values in code (theme: { preset: 'night', tokens: { surface: '#0b1020', 'ring-dash': 'none' } }), and palette: ['#β¦', '#β¦'] replaces the node colors. Children share their branch’s color in lighter and darker shades, and labels switch to light text on dark nodes on their own.
Browsers
Orbit is made for current browsers, and draws in older ones down to Chromium 99, which some phones’ WebViews still run: every change is checked in Chromium 99 itself. A few effects need newer CSS, and older browsers get plainer versions instead of broken ones:
- without
color-mix()(Chromium 111, Safari 16.2, Firefox 113), sibling ideas keep their branch’s color instead of a shade of it, and rims, rings, shadows and halos take the theme’s own colors; - without
hwb()(Chromium 101, Firefox 96), orlab(),lch(),oklab(),oklch()andcolor()(Chromium 111, Safari 15.4, Firefox 113), a node or palette color written in one is drawn in the sRGB color it stands for; - without the
translateproperty (Chromium 104), overlays are centered through their transform; - without the
dvhunit (Chromium 108), the detail sheet sizes byvh.
Cleanup
If you mount via renderOrbitElement and later remove the host from the DOM, call OrbitSVGRenderer.unmount(host) to release RAF + ResizeObserver resources. The <orbit-map> element does this automatically.