Docs Navigation (API Reference)›

@simplex-viz/react API Reference

Declarative <SimplexTopicGraph /> component, JSX custom node measurement, and imperative useSimplexGraphController() hook re-exporting all SVG and Core utilities.

  • @simplex-viz/react v1.0.0
  • Type-Safe React 18 & 19 Bindings
npm install @simplex-viz/react

Entry Points

@simplex-viz/react
DOM / Host·Side-effect free

Environment: React 18 & 19 (Browser DOM)

Declarative <SimplexTopicGraph /> component, JSX custom node measurement, controller & timeline hooks, and all SVG/Core re-exports.

Primary Exports

import { … } from '@simplex-viz/react'

Root entrypoint
SimplexTopicGraphComponent
<SimplexTopicGraph<
  TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta
>
  {...props}
/>

Primary responsive React component supporting presets, shapeOptions, getShape, badgeOptions, viewport edge-flipped built-in JSX tooltips (@simplex-viz/core/dom), reducedMotion, Shift+Click & Shift+Drag multi-selection (selectedIds, shiftClickSelects, marqueeSelection, onSelectionChange), structured legend subscriptions (onLegendChange), zero-relayout itemFilter/itemFilterMode, batched prop sync, WCAG 2.1 AA ariaLabel/keyboardNavigation, timeline playback, deferInitialLayout, mobile touchScrollLockPx/clickTolerancePx, JSX node renderers, and drill-down.

useSimplexGraphControllerHook
useSimplexGraphController<
  TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta
>(): {
  controllerRef: RefObject<SimplexSvgController<...> | null>;
  handle: SimplexGraphControllerHandle<TItem>;
}

Provides stable imperative access to live item mutations, multi-selection (setSelectedIds/toggleSelectedId/clearSelection/selectItemsInScreenRect), structured legend snapshots (getLegendModel), deep-linking (getViewState/restoreViewState), reducedMotion controls, setItemFilter(), linked-view setHighlightedIds()/focusItem()/zoomToItem(), exportSvg()/exportPng() snapshots, batch()/setOptions(), keyboard focus helpers, camera resets, relayout(), timeline access, and drillDown / drillUp actions.

useSimplexTimelineHook
useSimplexTimeline<TItem>(
  target: RefObject<SimplexSvgController<TItem, ...> | null> | SimplexTimelineController<TItem> | null,
): UseSimplexTimelineResult<TItem>

Reactive React hook subscribing to chronological timeline state with play, pause, toggle, stepBy, seek, and speed controls.

SimplexTopicGraphPropsInterface
interface SimplexTopicGraphProps<
  TItem, TContentVisual, TClusterVisual, TTagMeta, TClusterMeta
>

Conditional hybrid prop types enforcing getId / getTags only when TItem lacks id / tags and tags are required.

<SimplexTopicGraph /> Props Overview

<SimplexTopicGraph /> syncs declarative React prop updates into the underlying SimplexSvgController without remounting the SVG scene or interrupting active spring animations (using shared option-equality helpers from @simplex-viz/core plus viewport edge-flipped tooltips via @simplex-viz/core/dom):

import {
  SimplexTopicGraph,
  createSubspaceZoomStrategy,
  createCollisionDrivenLayoutStrategy,
  createSoftSimplexTagClusteringStrategy,
  useSimplexGraphController,
} from '@simplex-viz/react';

export function InteractiveAtlas({ articles }: { readonly articles: readonly Article[] }) {
  const { controllerRef, handle } = useSimplexGraphController<Article>();

  return (
    <div className="h-[640px] w-full">
      <SimplexTopicGraph
        controllerRef={controllerRef}
        items={articles}
        getId={(a) => a.slug}
        getTags={(a) => a.tags}
        getLabel={(a) => a.title}
        preset="glyphs"
        theme="dark"
        clusteringStrategy={createSoftSimplexTagClusteringStrategy({ triangleSpread: 0.45 })}
        layoutStrategy={createCollisionDrivenLayoutStrategy()}
        zoomStrategy={createSubspaceZoomStrategy()}
        showZoomBreadcrumbs
        itemFilter={(a) => a.tags.length > 0}
        itemFilterMode="dim"
        ariaLabel="Interactive research articles atlas"
        keyboardNavigation
        tooltip
        onZoomStateChange={(state) => {
          console.log('Current drill depth:', state.depth);
        }}
      />
    </div>
  );
}

Imperative Handle Methods (handle)

Returned by useSimplexGraphController():

  • Live Corpus Mutations & Filtering: handle.addItems(items), handle.removeItems(ids), handle.setItems(items), handle.setItemFilter(predicate, options?), handle.getItemFilter()
  • Multi-Selection & Deep-Linking: handle.setSelectedIds(ids), handle.toggleSelectedId(id), handle.clearSelection(), handle.getSelectedIds(), handle.selectItemsInScreenRect(rect, options?), handle.getViewState(), handle.restoreViewState(state, options?)
  • Linked-View Search & Navigation: handle.setHighlightedIds(ids), handle.getHighlightedIds(), handle.focusItem(itemId | null, options?), handle.getFocusedItemId(), handle.zoomToItem(itemId, options?)
  • Client-Side Snapshot Export: handle.exportSvg(options?), handle.exportPng(options?) (format: 'blob' | 'dataUrl', HiDPI scale)
  • Atomic Batching & Options: handle.batch(fn), handle.setOptions(options)
  • Hierarchical Drill-Down: handle.drillDownTriangle(index), handle.drillDownCluster(uid), handle.drillToNeighbor(neighborId), handle.drillUp(), handle.drillToDepth(depth), handle.drillToRoot(), handle.getZoomState()
  • Focus, Motion, Accessibility, Camera & Telemetry: handle.setFocusedTriangleIndex(index | null), handle.setReducedMotion(pref), handle.getReducedMotion(), handle.isReducedMotionActive(), handle.getKeyboardFocusTarget(), handle.clearKeyboardFocus(), handle.zoomBy(factor), handle.resetCamera(), handle.relayout(), handle.getMetrics(), handle.getClusters(), handle.getLegendModel(options?), handle.getTimeline(), handle.subscribeTimeline(listener)