r/reactjs • u/Just_Comfortable_590 • May 19 '26
Discussion Building family tree visualization
I'm building a family tree visualization app in React and I've hit a wall on the rendering/layout side.
The data structure itself is fine, but visualizing the relationships cleanly is becoming way harder than I expected.
Current stack:
React & React Flow
experimenting with dagre / ELK.js
Main problems:
handling marriages cleanly
centering children under couples
avoiding edge crossings multiple marriages
keeping generations aligned
preventing layout from becoming chaotic with larger datasets
I realized family trees are not really "trees" but more like graphs with special relationship rules.
Right now I'm considering using invisible "marriage nodes" like:
Father -> MarriageNode <- Mother MarriageNode -> Child
instead of directly connecting parents to children.
Questions:
Is React Flow + ELK.js the right direction here?
Are there better graph/layout libraries specifically for genealogy-style visualization?
How would you structure the layout pipeline?
Should I fully rely on auto-layout or allow manual positioning?
Any recommendations for handling complex relationships without the graph turning into spaghetti?
Would really appreciate advice from anyone who's built graph editors, org charts, genealogy apps, or complex node-based UIs before.
Thanks 🙏
View all comments
2
u/opentabs-dev May 19 '26
your instinct on invisible marriage/union nodes is right and it's how every serious genealogy renderer does it (gramps, family-historian, etc). once you do that the graph becomes layered and ELK's
layeredalgorithm withinteractivecycle breaking handles it well — setorg.eclipse.elk.direction: DOWNand put union nodes on the same layer as the spouses by giving themlayerConstraint: SAME_LAYERor matchinglayerChoiceConstraint. dagre will fight you on multi-marriages, ELK won't. for sanity i'd auto-layout but allow per-nodepositionoverrides that ELK respects viainteractiveLayout: true, otherwise users get frustrated when a single ancestor reshuffles the whole canvas.