Skip to content

Network Graph for React

A force-directed React network graph shows who is connected to whom, laid out by a simulation written in the component. Pass nodes (an id, with an optional group and value) and links (a source and a target id).

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/network-graph.json

Service dependencies

Use the arrow keys to move to the nearest node in that direction, Page Up and Page Down to step through every node in order, plus and minus to zoom and 0 to fit. Drag a node to move it; Ctrl or Command and scroll to zoom.

  • NetworkGraph
  • NetworkTable
  • defaultNetworkGraphLabels
  • +1 more

Service dependency map

Hover a service to light up what it talks to; drag it and the rest of the graph follows, then settles. Ctrl or ⌘ + scroll, a pinch or the buttons zoom; drag the background to pan. Remove the search services: the rest glide to their new places. Node size is the service's traffic.

Service dependencies

Production, calls in the last hour

30dependencies
  • Edge
  • Core services
  • Data stores
  • Third party
Use the arrow keys to move to the nearest node in that direction, Page Up and Page Down to step through every node in order, plus and minus to zoom and 0 to fit. Drag a node to move it; Ctrl or Command and scroll to zoom.

Collaboration network, weighted ties

Forty people in five teams; a tie's weight is how often two people worked together, and it sets the line's thickness. Names are printed only where they fit without colliding; zoom in and more appear.

Collaboration

Shared projects this quarter

  • Product
  • Design
  • Engineering
  • Data
  • Operations
Use the arrow keys to move to the nearest node in that direction, Page Up and Page Down to step through every node in order, plus and minus to zoom and 0 to fit. Drag a node to move it; Ctrl or Command and scroll to zoom.

Files to copy

13 folders · 29 files · 4 packages
From theme/src/
  • components/charts/{network-graph.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-tip.tsx, chart-utils.ts, flow-utils.tsx, heatmap.tsx}
  • components/charts/chart-parts/
  • components/charts/heatmap/
  • components/charts/network-graph/
  • components/drawer/parts/sheet.tsx
  • components/kbd/
  • components/menu/
  • components/skeleton/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts, use-resolved-scheme.ts}
  • motion/tokens.ts
  • lib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/network-graph.jsonRegistry item: network-graph. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react clsx motion tailwind-merge

Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".

Props

PropTypeDefaultDescription
nodes (required)readonly NetworkNode[]NoneThe nodes: { id, label?, group?, value? }. value sizes the dot.
links (required)readonly NetworkLink[]NoneTies between nodes (undirected). Repeated pairs add up; links to unknown ids are left out.
groupsreadonly NetworkGroup[]NoneNames and colour slots of the groups. Groups only named on nodes get the next free slot.
heightnumber420Height of the chart in px; the width follows the container.
showLabels"none" | "auto" | "all""auto"Which names to print: where they fit without colliding ("auto", default), all, or none.
forcesForceSimulationOptions{}Sets the tuning of the force layout.
format((n: number) => string)compact numbers in localeFormats node values.
localestring"en"Locale of the default number format.
onNodeClick((node: { id: string; label: string; group: string | null; connections: string[]; }) => void)NoneCalled with { id, label, group, connections } when a node is clicked, tapped, or activated with Enter.
emptyStateReactNodeNoneShown when there is nothing to plot.
labelsPartial<NetworkGraphLabels>defaultNetworkGraphLabelsEvery other string, for translation: labels={{ roleDescription: "…" }}; omitted keys keep the English of defaultNetworkGraphLabels. All 10 keys of NetworkGraphLabels are listed in the key table under the props table.
aria-label (required)stringNoneNames the chart for assistive tech (required).
classNamestringNoneAdds extra classes to the outer element.
NetworkGraphLabels keys and English defaults (10)
Pass any key in labels; the rest keep the defaults of defaultNetworkGraphLabels.
KeyEnglish default
roleDescriptionnetwork graph
instructionsUse the arrow keys to move to the nearest node in that direction, Page Up and Page Down to step through every node in order, plus and minus to zoom and 0 to fit. Drag a node to move it; Ctrl or Command and scroll to zoom.
hintTap a node to see its connections
connections(count) => (count === 1 ? "connection" : "connections")
valuevalue
connectedTo(names, more) => `Connected to ${names.join(", ")}${more > 0 ? ` and ${more} more` : ""}`
zoomInZoom in
zoomOutZoom out
fitFit to view
zoomControlsZoom

NetworkTable props

PropTypeDefaultDescription
format((n: number) => string)compact numbers in localeFormats node values.
localestring"en"Locale of the default number format.
groupsreadonly NetworkGroup[]NoneNames and colour slots of the groups. Groups only named on nodes get the next free slot.
nodes (required)readonly NetworkNode[]NoneThe nodes: { id, label?, group?, value? }. value sizes the dot.
links (required)readonly NetworkLink[]NoneTies between nodes (undirected). Repeated pairs add up; links to unknown ids are left out.
captionstringNoneHidden caption that names the table for screen readers.
headersPartial<{ node: string; group: string; connections: string; value: string; linked: string; }>NoneOverride the column headers: { node, group, connections, value, linked }.
emptyStateReactNodeNoneShown when there are no rows.

Keyboard

KeysAction
TabFocus the graph, then the zoom buttons.
←/→/↑/↓Move to the nearest node in that direction (the view pans to keep it in sight).
Page Down/Page UpNext / previous node in data order.
Home/EndFirst / last node.
+/−Zoom in / out.
0Fit the whole graph.
Enter/SpaceCall onNodeClick for the active node.
EscapeClear the reading.

Accessibility

  • The graph is one focusable figure with the role description “network graph”; a node is announced with its group, its connections and up to eight neighbor names.
  • The Table view (NetworkTable) is the keyboard list of every node and who it connects to.
  • Zoom buttons are real buttons (44px on touch). A plain scroll never hijacks the page: zoom needs Ctrl/⌘, a pinch or the buttons; one finger on the background still scrolls.
  • Every moving frame (layout, entrance, drag, pan, zoom) is written straight to the SVG, so the page stays smooth while you drag on a phone.
  • Reduced motion: the precomputed layout appears in place, and dragging moves only that node.

All exports on this page

  • NetworkGraph — Who is connected to whom: services and their dependencies, people who work together, linked pages.
  • NetworkTable — Every node with its group, its number of connections and who it connects to.
  • defaultNetworkGraphLabels — The built-in English strings of NetworkGraph; spread it into your own labels and change what you need.

When to use the network graph

  • Use it as a node graph to map service dependencies, where each node is a microservice sized by traffic and a link shows that two services are connected (links are undirected), so you can see which service everything depends on.
  • It fits a collaboration or org network, such as forty people in five teams, with link value as how often two people worked together and group colors showing the team.
  • It also works for a site's internal link structure or a social graph, where clusters and bridge nodes matter more than precise numbers, and where a user can click a node to open details.
  • Skip it when the connections have direction and quantity that must be compared; a Sankey diagram handles weighted flows, and ChordDiagram suits a dense matrix of relationships between a few groups.
  • Pair it with ChartCard for the legend and Chart / Table tabs, NetworkTable as the text twin listing each node's connections, and onNodeClick to open a detail Drawer.

Frequently asked questions

48 charts pages in all: browse them on Charts.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .