Power Network

A composable, animated network diagram that shows live power flows between sources, the home, and connected devices.

520 W
3,200 W
1,000 W
0 W

Usage

import {
  PowerDevice,
  PowerNetworkDevices,
  PowerNetworkDiagram,
  PowerNetworkHome,
  PowerNetworkSources,
  PowerSource,
} from '@epilot/spark-ui/power-network'
<PowerNetworkDiagram title="Power Flow">
  <PowerNetworkSources>
    <PowerSource variant="grid" watts={520} icon={<GridIcon />} />
    <PowerSource variant="solar" watts={3200} icon={<SolarIcon />} />
    <PowerSource variant="battery" watts={1000} icon={<BatteryIcon />} />
  </PowerNetworkSources>
  <PowerNetworkHome autarky={0.89} />
  <PowerNetworkDevices>
    {devices.map((d) => (
      <PowerDevice key={d.id} watts={d.power} icon={d.icon} />
    ))}
  </PowerNetworkDevices>
</PowerNetworkDiagram>

The diagram is composable: each row is its own component, and each bubble registers itself with the parent via context. Sources, devices, and the home node can be added dynamically; connectors are drawn between whichever children are mounted.

The connector animation dash gap, scroll speed, and opacity derive from each node's share of the home's total consumption, so a higher-power flow visibly "moves faster". Connectors snap to a straight line when source and home (or home and device) are vertically aligned, and curve otherwise, so with two devices both lines curve, but a single centred device gets a straight line.

At 0 W the moving dashes cross-fade into a static grey line, so an idle node still reads as wired up instead of disconnected.

Examples

Full network

A complete layout with three sources and three devices.

4,400 W
800 W
0 W
0 W
2,200 W
900 W
400 W

Idle vs. standby

Both the grid and the battery are at 0 W. The grid grays out, while the battery passes standby to keep its colors, so it reads as online and charged but not in use. Either way the connector stays visible as a static grey line.

0 W
1,800 W
0 W
0 W

Loading

Pass loading to swap node icons for skeletons while data is in-flight.

API Reference

PowerNetworkDiagram

PropTypeDefault
titlestring
loadingbooleanfalse
classNamestring
childrenReactNode

PowerNetworkSources / PowerNetworkDevices

Row containers for source and device bubbles.

PropTypeDefault
classNamestring
childrenReactNode

PowerNetworkHome

PropTypeDefault
wattsnumberSum of registered source watts
autarkynumberundefined (0..1, hides ring when omitted)
classNamestring

PowerSource

PropTypeDefault
wattsnumberrequired
iconReactNoderequired
variant'grid' | 'solar' | 'battery' | 'neutral''neutral'
progressnumberundefined (0..100, hides ring when omitted)
standbybooleanfalse
idstringauto-generated
classNamestring

PowerDevice

PropTypeDefault
wattsnumberrequired
iconReactNoderequired
namestring
idstringauto-generated
classNamestring

On this page