Skip to content
animorio
IT
Back to the library

Family tree

SVG, HoverGSAP, CSS onlyMediumCompressed weight: Demo 6.2 KBGSAP 28 KBFreeDownload the zip

A family tree over three generations: twelve people in circles with their initial, tied by thin branches that draw themselves from the top. Pick a person and the stretch of branches tying them to you lights up in coral, one piece after the other, those along the way take an edge and the others fade; below, the name, the kinship and how many steps apart you are roll in.

The code

A folder that runs on its own: index.html, style.css, script.js and the libraries from a CDN. The React and Vue tabs hold the same demo as a ready component, which switches its animations off when it leaves the page.

<!doctype html>
<!--
  "Family tree" from Animorio · https://animorio.com
  License: free on your own sites and your clients’ sites, paid work included.
  Not for resale, redistribution, templates or code collections · https://animorio.com/en/license/
-->
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Family tree</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <!-- a family tree over three generations: the branches draw themselves, and whoever is picked lights
         the line that ties them to you while the kinship rolls in below -->
    <section class="ft" data-ft aria-labelledby="ft-title">
      <header class="ft__head">
        <span class="ft__name"><b id="ft-title">Family tree</b><span>Three generations</span></span>
        <span class="ft__steps" aria-hidden="true"><span data-steps>You</span></span>
      </header>

      <div class="ft__tree" data-tree>
        <svg viewBox="0 0 296 190" preserveAspectRatio="none" aria-hidden="true">
          <path class="ft__line" data-edge data-a="m1" data-b="tomas" pathLength="1" d="M68 26H55"></path>
          <path class="ft__line" data-edge data-a="m1" data-b="ines" pathLength="1" d="M68 26H81"></path>
          <path class="ft__line" data-edge data-a="m2" data-b="kofi" pathLength="1" d="M228 26H215"></path>
          <path class="ft__line" data-edge data-a="m2" data-b="marta" pathLength="1" d="M228 26H241"></path>
          <path class="ft__line" data-edge data-a="m3" data-b="noel" pathLength="1" d="M148 96H121"></path>
          <path class="ft__line" data-edge data-a="m3" data-b="ada" pathLength="1" d="M148 96H175"></path>
          <path class="ft__line" data-edge data-a="m1" data-b="lena" pathLength="1" d="M68 26V61H30V81"></path>
          <path class="ft__line" data-edge data-a="m1" data-b="noel" pathLength="1" d="M68 26V61H106V81"></path>
          <path class="ft__line" data-edge data-a="m2" data-b="ada" pathLength="1" d="M228 26V61H190V81"></path>
          <path class="ft__line" data-edge data-a="m2" data-b="ben" pathLength="1" d="M228 26V61H266V81"></path>
          <path class="ft__line" data-edge data-a="m3" data-b="zoe" pathLength="1" d="M148 96V131H112V151"></path>
          <path class="ft__line" data-edge data-a="m3" data-b="you" pathLength="1" d="M148 96V151"></path>
          <path class="ft__line" data-edge data-a="m3" data-b="sam" pathLength="1" d="M148 96V131H184V151"></path>
          <path class="ft__line" data-edge data-a="lena" data-b="rui" pathLength="1" d="M30 111V151"></path>
          <path class="ft__hot" data-hot data-a="m1" data-b="tomas" pathLength="1" d="M68 26H55"></path>
          <path class="ft__hot" data-hot data-a="m1" data-b="ines" pathLength="1" d="M68 26H81"></path>
          <path class="ft__hot" data-hot data-a="m2" data-b="kofi" pathLength="1" d="M228 26H215"></path>
          <path class="ft__hot" data-hot data-a="m2" data-b="marta" pathLength="1" d="M228 26H241"></path>
          <path class="ft__hot" data-hot data-a="m3" data-b="noel" pathLength="1" d="M148 96H121"></path>
          <path class="ft__hot" data-hot data-a="m3" data-b="ada" pathLength="1" d="M148 96H175"></path>
          <path class="ft__hot" data-hot data-a="m1" data-b="lena" pathLength="1" d="M68 26V61H30V81"></path>
          <path class="ft__hot" data-hot data-a="m1" data-b="noel" pathLength="1" d="M68 26V61H106V81"></path>
          <path class="ft__hot" data-hot data-a="m2" data-b="ada" pathLength="1" d="M228 26V61H190V81"></path>
          <path class="ft__hot" data-hot data-a="m2" data-b="ben" pathLength="1" d="M228 26V61H266V81"></path>
          <path class="ft__hot" data-hot data-a="m3" data-b="zoe" pathLength="1" d="M148 96V131H112V151"></path>
          <path class="ft__hot" data-hot data-a="m3" data-b="you" pathLength="1" d="M148 96V151"></path>
          <path class="ft__hot" data-hot data-a="m3" data-b="sam" pathLength="1" d="M148 96V131H184V151"></path>
          <path class="ft__hot" data-hot data-a="lena" data-b="rui" pathLength="1" d="M30 111V151"></path>
        </svg>
        <button class="ft__p" type="button" data-p="tomas" data-name="Tomas" data-rel="Your grandfather" style="left:13.514%;top:26px" aria-pressed="false" aria-label="Tomas. Your grandfather"><span>T</span></button>
        <button class="ft__p" type="button" data-p="ines" data-name="Ines" data-rel="Your grandmother" style="left:32.432%;top:26px" aria-pressed="false" aria-label="Ines. Your grandmother"><span>I</span></button>
        <button class="ft__p" type="button" data-p="kofi" data-name="Kofi" data-rel="Your grandfather" style="left:67.568%;top:26px" aria-pressed="false" aria-label="Kofi. Your grandfather"><span>K</span></button>
        <button class="ft__p" type="button" data-p="marta" data-name="Marta" data-rel="Your grandmother" style="left:86.486%;top:26px" aria-pressed="false" aria-label="Marta. Your grandmother"><span>M</span></button>
        <button class="ft__p" type="button" data-p="lena" data-name="Lena" data-rel="Your aunt" style="left:10.135%;top:96px" aria-pressed="false" aria-label="Lena. Your aunt"><span>L</span></button>
        <button class="ft__p" type="button" data-p="noel" data-name="Noel" data-rel="Your father" style="left:35.811%;top:96px" aria-pressed="false" aria-label="Noel. Your father"><span>N</span></button>
        <button class="ft__p" type="button" data-p="ada" data-name="Ada" data-rel="Your mother" style="left:64.189%;top:96px" aria-pressed="false" aria-label="Ada. Your mother"><span>A</span></button>
        <button class="ft__p" type="button" data-p="ben" data-name="Ben" data-rel="Your uncle" style="left:89.865%;top:96px" aria-pressed="false" aria-label="Ben. Your uncle"><span>B</span></button>
        <button class="ft__p" type="button" data-p="rui" data-name="Rui" data-rel="Your cousin" style="left:10.135%;top:166px" aria-pressed="false" aria-label="Rui. Your cousin"><span>R</span></button>
        <button class="ft__p" type="button" data-p="zoe" data-name="Zoe" data-rel="Your sister" style="left:37.838%;top:166px" aria-pressed="false" aria-label="Zoe. Your sister"><span>Z</span></button>
        <button class="ft__p is-you" type="button" data-p="you" data-name="You" data-rel="This is you" style="left:50.000%;top:166px" aria-pressed="true" aria-label="You. This is you"><span>Y</span></button>
        <button class="ft__p" type="button" data-p="sam" data-name="Sam" data-rel="Your brother" style="left:62.162%;top:166px" aria-pressed="false" aria-label="Sam. Your brother"><span>S</span></button>
      </div>

      <footer class="ft__foot">
        <span class="ft__who" aria-live="polite"><b class="ft__roll"><span data-who>You</span></b><span class="ft__roll ft__roll--sub"><span data-kin>This is you</span></span></span>
        <button class="ft__back" type="button" data-back disabled>Back to you</button>
      </footer>
    </section>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.200 19.200 11l-6.300 1.600-3.300 5.900Z"></path></svg>
  </main>

  <script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
  <script src="script.js"></script>
</body>
</html>

Playground

Change values, colours and text with the controls and watch the animation respond live. Or write in the code yourself. Then download the folder with your changes.

30 values to change

Works with Claude, Claude Code, ChatGPT, Cursor, VS Code, Windsurf, Codex, Gemini CLI

Or ask your AI assistant for it

With the Animorio connector, Claude Code, ChatGPT, Cursor or VS Code take it from here, guide included, and fit it into your project. Paste this request:

Take “Family tree” from Animorio and fit it into my site
Platform licenseFree on your sites and your clients’ sites. Want it inside a website builder, a template platform or a client dashboard? There’s a license for agencies and platforms.

What it does

On black, a dark card: “Family tree”, “Three generations” and on the right a coral pill, “You”. On opening the branches draw themselves from the top, generation after generation, and the people pop out row by row: four grandparents at the top, joined in couples, their children in the middle, and at the bottom a cousin, a sister, you (the circle with the white edge) and a brother. Below, “You”, “This is you” and the “Back to you” button, off. Tap grandmother “I” and her circle turns coral with a halo and bounces; from her branches a coral line runs down to your father and from him to you, one stretch after the other, and your father takes a coral edge with a small hop. The others fade. Below, “Ines” and “Your grandmother” roll in, at the top “2 steps away”. With the uncle the line climbs to the maternal grandparents and comes back down through your mother; with the cousin it goes through the aunt, the grandparents and your father: “3 steps away”. “Back to you” puts everything out.

How it works

The tree is a graph

People and the points where a couple meets are nodes, branches are edges. Each branch is an SVG path with pathLength 1 and two attributes saying which nodes it joins; people are real buttons laid on top, in percentages.

The way to you

A breadth-first walk from the chosen node to “you” returns the branches crossed, in order, and the direction each is travelled in.

The running line

On top of each branch sits its coloured copy. Those on the way are drawn one after the other by animating stroke-dashoffset from 1 or from minus 1 to 0, depending on direction, so the line looks like a single one running.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#ff7d6bThe colour of the person picked and of the line tying them to you.
DRAWscript.js0.32How long each stretch of the line takes to draw.
GROWscript.js1.1How long the branches take to draw on opening.

Try them in the Playground

When to use it

In genealogy apps, family albums and family history sites; and, changing the names, for a company org chart, the lineage of a grape or a breed, the dependencies between the parts of a project.

On phones

The same card, as wide as the screen minus the margins: the branches stretch across the width and the people follow in percentages. The circles are 30 pixels wide but the tappable area is 44. The card is about 315 pixels tall and fits whole in the phone box.

With reduced motion

The tree is already drawn on opening. On picking a person the coral line appears all at once, the circles change colour with no bounces and the labels change without rolling. The demo’s pointer does not start.

Pitfalls

  • Family and names are made up, and the kinships are written by hand for twelve people: in a real tree they are worked out from the graph, and families are not always two parents and their children.
  • Who is on the way is not told by colour alone: the edge changes, the others fade and the kinship is written below and in each button’s label.
  • The branches are stretched with preserveAspectRatio none: the stroke keeps its width only with vector-effect non-scaling-stroke.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

Compressed with gzip, the three demo files weigh 6.2 KB; the libraries: GSAP 28 KB.

Testing

Tested on 25 November 2026

  • Desktop: Done
  • Phone: Done
  • Reduced motion: Done
  • Safari on iPhone: To do

License

Use it in your own projects and in your clients’ projects. Do not resell it or redistribute it as is. GSAP stays under its own Standard license. Full license.

All animations