React components for OneTaxonomy: a server-renderable SVG tree, an accessible keyboard outline of the same tree, and an explorer with undo/redo. Every interaction is a view action from @extantape/onetaxonomy-core, so the scientific data never changes and views can be saved, shared and replayed.
import { createView, indexDataset } from '@extantape/onetaxonomy-core'
import { Explorer } from '@extantape/onetaxonomy-react'
import '@extantape/onetaxonomy-react/styles.css'
const data = indexDataset(snapshot)
const view = createView(data, { id: 'turtles', title: 'Turtles', target: { kind: 'classification', id: 'my-classification' } })
<Explorer dataset={data} initialView={view} title="Turtles" onViewChange={save} />TreeView: SVG with no effects, so it renders on the server (large trees switch to a canvas, below).role="img"with a title and a description that says whether it is a classification or a phylogeny and how much is shown. Stableot-*classes anddata-*states (status, rank, collapsed, selected); extinct taxa are marked †. In rectangular layouts an inner node's name sits on the node's row, or just above or below it, wherever the branches to its children leave room; a folded branch's name starts past its triangle. A long name can still cross a branch further down the tree.- Large trees:
TreeViewdraws on a canvas above 1,000 drawn nodes (CANVAS_THRESHOLD; change it withcanvasThreshold, or force one withrenderer="svg"or"canvas"). Folded branches count down, so folding a big tree can bring it back to SVG. The canvas uses the same layout, the same highlight shapes and colors, and the same title and description; it is onerole="img", and the outline is still the way in with the keyboard. It fills its container (give the container a height) unless you passcanvasSize, and it's drawn at the screen's pixel density. Level of detail:- A name or support value is drawn only when its text would be at least 9 px tall (
lod.minLabelPx) and wouldn't overlap a name already placed. In radial layouts a leaf's name needs its neighbours at least that far away. The selection's name is always drawn, at 9 px or more. - A subtree with two or more leaves that would all sit within 1 px (
lod.mergeBelowPx; across the leaves, or along the outer circle in radial layouts) is drawn as one wedge. A wedge holding a highlight shows the highlight. The selection and the drop target are never merged away. - What's left out is counted and said: in the description and in a note under the drawing ("891 branches are too small to draw at this zoom and are shown as wedges holding 18,218 nodes. 891 names and values are too small or crowded to show. Zoom in to see them."). Replace the wording with
lodNoteandmergedLabel. - Clicks are hit-tested (a node's dot, its name or its wedge), so
onNodeClickand the explorer's select, fold and drag work as on the SVG.canvasNodeAtdoes the same from your own pointer handlers. - In the explorer, PNG download draws the canvas in the light colors with the disclosure underneath. SVG download isn't available for a canvas tree, and it says so.
- The planning is pure and exported (
prepareTree,planCanvas,hitTest,drawPlan,describeLod). Timings in Node are indocs/benchmarks.md. - Frame times in a browser are in
docs/benchmarks-browser.md, from one machine: headless Chrome 157 and a headless build of WebKit 27.2 on an M2 Max Mac, on 2026-11-11, with other work running. The Chrome numbers first. Panning, zooming and scrolling a 1000 px square drawing, the canvas kept to the display's 60 frames a second at every size tried, up to 19,999 nodes, and still did with Chrome slowing the main thread 4 times. SVG kept up through 1,999 nodes and fell to about 30 frames a second at 4,999. With the main thread slowed 4 times, SVG kept up at 499 nodes and dropped frames at 999 (58% late while zooming). So the default switch at 1,000 drawn nodes has room to spare on a fast machine and is a little high for a slow one: if your readers are on slow devices, trycanvasThreshold={500}. In WebKit (Playwright's build, the engine Safari and the Mac app use but neither program), the canvas also kept to 60 frames a second at every size, and SVG kept up through 1,999 nodes and dropped frames at 4,999 (33% to 56% late while panning); there is no slowed-thread run there. Not measured: Safari itself, the Mac app's web view, Firefox, a window on a real screen, a real slow device, and radial layouts.
- A name or support value is drawn only when its text would be at least 9 px tall (
- On a server (Next.js App Router, React Server Components). The package can be imported from a Server Component.
TreeViewrenders there as SVG with no JavaScript sent for it:<TreeView projection={projection} layout={layoutFor(projection, 'rectangular')} highlights={[]} title="Turtles" />. Pass it no handlers on a server, since functions can't cross to the browser.TreeOutline,Explorer,Legend,LessonPlayer,TipLinker,ComparePanel,SupportControlandCanvasTreeVieware client components ('use client'): render them from a Server Component with plain data as props, and they run in the browser. A tree over the canvas threshold is handed toCanvasTreeView, so it's drawn in the browser; that path hasn't been tried from a Server Component yet. Plain functions that live in the client files can only be called in the browser for now:canvasNodeAt,canvasPlanOf,canvasPng,cameraBox,rootedRecord,supportSummary,tipsUnder,proposeTipLinks,linkedPhylogeny, thePHYLO_LABELS,TIP_LINK_LABELSandDEFAULT_CANVAS_SIZEvalues, and the hooks. Everything else (layoutFor,treeViewBox, the canvas planning, shapes, export, drag and near-name helpers) works in both places.apps/payload-exampledraws its public pages this way. TreeOutline: the WAI-ARIA tree pattern: one tab stop, arrows, Right/Left to open/close, Home/End, type-ahead, Space to select (Shift+Space adds to the selection), Enter to open a branch,*to open its siblings, Alt+Up/Down to reorder (the keyboard alternative to dragging). Folded descendants are announced ("12 not shown"), and † is read as "extinct".Explorer: toolbar (undo, redo, expand/collapse all, layout, living/extinct/unknown filter), drawing, outline and inspector (rank, status, highlights with clade or group and the hypothesis they were assessed against, flip children, show only this branch). Layouts the data can't support stay disabled, and the reason is written under the toolbar. The toolbar is one Tab stop: Left and Right move between its controls, Home and End jump (in the number field the arrows stay with the field). Everything you can do by dragging has a button: Move up and Move down in the inspector reorder a taxon among its siblings, and the drawing controls pan left, right, up and down. With the drawing focused, arrow keys pan, + and − zoom, 0 fits and Escape clears the selection; the inspector's hint lists the outline keys. Highlights and trait states are drawn in different shapes as well as colors (twelve: circle, square, diamond, four triangles, hexagon, star, plus, cross and hourglass; they repeat after twelve), and the legend shows the same shapes. Nodes in the drawing aren't Tab stops: the outline is the keyboard path to each taxon (ADR 0010). All text is replaceable throughlabels.- Phylogeny controls in
Explorer. "Collapse support below" takes a number and applies it on Enter or when you leave the field (one undo step), with a Clear button; what it collapsed is said in a status region ("3 branches below 70 collapsed; 2 have no support value"). For a classification it's disabled, with the reason shown. "Compare with…" appears when the dataset has another phylogeny or you passcompareWith: it gives the Robinson-Foulds distance, raw and normalized, the tips in only one tree, the clades (rooted) or splits (unrooted) that differ, and the reason when the trees can't be compared, such as tips not mapped to taxa. It runs only while the panel is open. PassonRootedto get "Midpoint root" in the toolbar and "Root on this tip/clade (outgroup)" in the inspector: each builds a new phylogeny record with a new id and arootingnote and passes it to you. The record shown is never changed, and where the new one goes is up to you. The Mac app adds it to a new snapshot. A record'srootingnote is shown under the toolbar and in About, exports and prints. TipLinker: confirm which taxon each tip of a tree stands for, so trees read from Newick, NEXUS or phyloXML can be compared. It proposes matches by exact name (letter case aside) among the dataset's taxa and synonyms and applies none of them until you accept: per tip, or all exact unique matches at once with a button that says how many. Several taxa with the same name are all offered, with their authorship, rank, source and id; tips can be linked to a taxon found by another exact name, or left unlinked, and the unlinked ones are listed. Where nothing matches exactly, a separate "Possible matches, not exact" list offers near names: the same name apart from underscores, spacing or letter case; the same once a trailing specimen code or voucher is left off ("Chelonoidis_carbonarius_MZUSP1234" → Chelonoidis carbonarius); or one letter different (names of five letters or more). Each says which rule found it, none is linked until you choose it, and "Accept all" never takes them (nearNameMatches). Trees with more than 200 tips (pageSize) are paged, and the table can be narrowed to one kind of match. Confirming passes you a new phylogeny record with the links in each tip'sconcepts; the record shown never changes. A link made from a near name is recorded asnear-name-confirmed, with the name and the rule. Keyboard and screen reader: it's a table with row and column headers, native selects and buttons, focus moves to its title, and each decision is announced.proposeTipLinksandlinkedPhylogenyare the same steps without the UI.useTaxonomyView: the headless state (view, projection, dispatch, undo/redo) for your own UI.- Styles are optional (
styles.css, CSS custom properties, dark mode, reduced motion). The default light and dark themes meet WCAG 2.2 AA contrast for text (4.5:1) and lines and field borders (3:1); a test computes the ratios from the stylesheet. One known exception: the brand-orange focus ring is 2.88:1 on the panel color (3.07:1 on the drawing).
Try it: pnpm build && pnpm --filter @extantape/onetaxonomy-playground build, then open apps/playground/dist/index.html.