Backgrounds

NodeGraphBackground

A neural network, conceptually.

Canvas-rendered drifting nodes with proximity-based links. Reacts to the cursor (pulls nodes within `hoverDistance`). Zero JS dependencies.

Install

Copy this owned-code component into your app from the registry.

pnpm dlx shadcn-svelte@latest add https://benjamin-brady.github.io/performative-ui-svelte/registry/node-graph.json

Examples

Default
<div style={{ position: "relative", height: 280 }}>
  <NodeGraphBackground />
</div>
Sparse + green
<NodeGraphBackground
  density={35}
  linkColor="#22c55e"
  colors={["#86efac", "#22c55e"]}
  linkDistance={180}
/>

Props

PropTypeDefaultDescription
densitynumber70Number of nodes.
speednumber0.4Pixel speed per frame.
linkDistancenumber140Max px between linked nodes.
colorsstring[]-Pool of node colors.
linkColorstring"#7c3aed"Link stroke color.
baseOpacitynumber0.45Resting alpha of nodes + edges. Field is dim at rest; cursor brightens it.
hoverDistancenumber200Radius of cursor effects (gravity + brighten). 0 disables both.
hoverGravitynumber0.0050–1 strength of cursor pull. Default is very subtle drift; set higher for stronger attraction.
hoverBrightennumber0.80–1 strength of opacity boost near the cursor.
overscannumber80px the simulation world extends past the visible viewport, nodes bounce off the world edges, drifting in/out of view.
Next FloatingSparkles ]