Skip to content
animorio
IT
All components

Branching comment thread

Trees, SVG, TransitionsGSAP, CSS onlyMediumCompressed weight: Demo 9.2 KBGSAP 28 KBFreeDownload the zip

The comment thread on one frame of a design file, in a dark card like a Dribbble shot: the replies hang from the comment above on thin branches drawn in SVG. Opening the replies the branches grow out of the avatar and bend with a round elbow towards each reply, the replies settle one after the other with a pixel of bounce, a small light runs down every new branch and the open comment's avatar takes a thin ring. Votes roll their number, the replies chip rolls its words and turns its chevron on a spring.

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>
<!--
  "Branching comment thread" 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>The comment thread with branches that open</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">
    <!-- the comment thread on a frame of a design file, in an invented design tool (Kestrel). The replies hang from
         their parent on thin branches drawn in SVG: opening a thread the branches grow out of the avatar, the
         replies settle in one after the other and a small light runs down each new branch -->
    <div class="ct" data-wrap>
      <span class="ct__glow" aria-hidden="true"></span>
      <article class="ct__card" data-card aria-label="Comments on Checkout, Frame 12">
        <span class="ct__shine" data-shine aria-hidden="true"></span>

        <header class="ct__head">
          <span class="ct__file">
            <svg class="ct__frame" viewBox="0 0 16 16" aria-hidden="true"><path d="M5 2.5v11M11 2.5v11M2.5 5h11M2.5 11h11"/></svg>
            <span class="ct__name">Checkout</span>
            <span class="ct__sep">/</span>
            <span class="ct__muted">Frame 12</span>
          </span>
          <span class="ct__state">Open</span>
        </header>

        <div class="ct__thread" data-thread>
          <svg class="ct__branches" data-branches aria-hidden="true">
            <defs>
              <filter id="ct-glow" x="-50%" y="-50%" width="200%" height="200%"><feGaussianBlur stdDeviation="2.2"/></filter>
            </defs>
          </svg>

          <div class="c c--root" data-c="mara">
            <span class="c__av c__av--peach" data-av>MO</span>
            <div class="c__body">
              <p class="c__meta">
                <span class="c__who">Mara Okafor</span><span class="c__time">2h</span>
                <button class="vote" type="button" data-vote aria-pressed="false" aria-label="Upvote, 14">
                  <svg class="vote__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 9.6 8 6.1l3.5 3.5"/></svg>
                  <span class="vote__n" data-n>14</span>
                </button>
              </p>
              <p class="c__text">Can the order total live in the sticky bar? It gets lost on small screens.</p>
              <button class="more" type="button" data-more="mara" aria-expanded="false" aria-controls="kids-mara">
                <span class="more__faces" aria-hidden="true"><span class="c__av c__av--mini c__av--blue">TL</span><span class="c__av c__av--mini c__av--mint">IR</span></span>
                <span class="more__label" data-label data-closed="2 replies" data-opened="Hide replies"><span>2 replies</span></span>
                <svg class="more__chev" data-chev viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 6.4 8 9.9l3.5-3.5"/></svg>
              </button>
            </div>
          </div>

          <div class="kids" id="kids-mara" data-kids="mara">
            <div class="kids__in">
              <div class="c" data-c="theo" data-parent="mara">
                <span class="c__av c__av--blue" data-av>TL</span>
                <div class="c__body">
                  <p class="c__meta">
                    <span class="c__who">Theo Lind</span><span class="c__time">1h</span>
                    <button class="vote" type="button" data-vote aria-pressed="false" aria-label="Upvote, 6">
                      <svg class="vote__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 9.6 8 6.1l3.5 3.5"/></svg>
                      <span class="vote__n" data-n>6</span>
                    </button>
                  </p>
                  <p class="c__text">Tried it. It hides the promo field.</p>
                  <button class="more" type="button" data-more="theo" aria-expanded="false" aria-controls="kids-theo">
                    <span class="more__faces" aria-hidden="true"><span class="c__av c__av--mini c__av--mint">IR</span></span>
                    <span class="more__label" data-label data-closed="1 reply" data-opened="Hide"><span>1 reply</span></span>
                    <svg class="more__chev" data-chev viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 6.4 8 9.9l3.5-3.5"/></svg>
                  </button>
                </div>
              </div>

              <div class="kids kids--deep" id="kids-theo" data-kids="theo">
                <div class="kids__in">
                  <div class="c" data-c="ines" data-parent="theo">
                    <span class="c__av c__av--mint" data-av>IR</span>
                    <div class="c__body">
                      <p class="c__meta">
                        <span class="c__who">Ines Ruiz</span><span class="c__time">48m</span>
                        <button class="vote" type="button" data-vote data-auto-vote aria-pressed="false" aria-label="Upvote, 8">
                          <svg class="vote__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 9.6 8 6.1l3.5 3.5"/></svg>
                          <span class="vote__n" data-n>8</span>
                        </button>
                      </p>
                      <p class="c__text">Make the promo a link above it?</p>
                    </div>
                  </div>
                </div>
              </div>

              <div class="c" data-c="ines2" data-parent="mara">
                <span class="c__av c__av--mint" data-av>IR</span>
                <div class="c__body">
                  <p class="c__meta">
                    <span class="c__who">Ines Ruiz</span><span class="c__time">40m</span>
                    <button class="vote" type="button" data-vote aria-pressed="false" aria-label="Upvote, 3">
                      <svg class="vote__icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M4.5 9.6 8 6.1l3.5 3.5"/></svg>
                      <span class="vote__n" data-n>3</span>
                    </button>
                  </p>
                  <p class="c__text">And tabular figures, so no jumps.</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </article>
    </div>
    <p class="sr" aria-live="polite" data-live></p>
  </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.

48 values to change

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 “Branching comment thread” 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 a near black page with two faint lights and a very fine grain a dark card with round corners rises slowly: at the top the frame symbol, ‘Checkout / Frame 12’ and a small ‘Open’ label. Below is Mara Okafor's comment, with a peach avatar and initials, the time, the ‘14’ vote with its chevron on the right, the question about the total bar and a chip with the faces of the two who replied and ‘2 replies’. Tapped, the chip gives and springs back, its words roll into ‘Hide replies’, the chevron turns over and Mara's avatar takes a thin periwinkle ring. The space opens: out of the avatar comes a thin line that runs down and bends with a round elbow towards each reply, while Theo's and Ines's replies come in one after the other, out of a slight blur, passing their place by a pixel; a small periwinkle light runs down every branch just born and fades at its end. Then Theo's reply opens: a shorter branch leaves his avatar for Ines's reply, and the reply below moves down to make room, its branch growing longer. Ines gets a vote: the chevron jumps and comes back, a thin ring widens and fades, the number rolls from 8 to 9 and the vote turns periwinkle. After a moment the thread folds back: the replies fade from the bottom, the branches pull back into the avatar, the space closes and the loop starts again. With the mouse a soft light follows the pointer inside the card and the top edge catches it; pointing at a reply lights its branch all the way to the top.

How it works

Replies clipped by height

Every reply list is a box with height 0 and overflow hidden. Opening it GSAP goes from the current height to the content's with expo.out and then sets height auto, so a reply opened further down stretches it by itself; closing it goes back to 0 with power3.inOut.

The branches are one path per reply

An SVG as big as the thread holds one path for each reply: it starts under the parent's avatar, runs down with V, bends with an 8 pixel A arc and reaches the reply's avatar with H. The positions come from getBoundingClientRect divided by the page's scale, recomputed every frame but written only when they change.

Growing and pulling back

With pathLength 1 and strokeDasharray 1 1, each branch grows by taking strokeDashoffset from 1 to 0, staggered like the replies. The running light is a dash 0.16 long on two copies of the same path, one sharp and one through a feGaussianBlur.

Rolling words and numbers

The chip and the vote put the new word next to the old one in a window one line tall: one rises with yPercent and fades, the other comes up from below with back.out; meanwhile the width goes from the old size to the new one and is then set free.

The springs of the taps

Every tap squeezes the button to 0.93 in 0.09 seconds and brings it back with elastic.out; the vote's chevron jumps 3.5 pixels and springs back, the open avatar's ring grows with back.out through a CSS variable.

Values to change

NameFileDefaultWhat it changes
SPEEDscript.js12 = everything twice as fast, 0.5 = half.
BRANCH_TIMEscript.js0.7How long a branch takes to grow, in seconds.
STAGGERscript.js0.09The delay between one reply and the next, in seconds.
BOUNCEscript.js1.7How far the replies pass their place before settling (0 = none).
ELBOWscript.js8The radius of the branch's turn, in pixels.
PULSEscript.jstrueA small light runs down every branch that opens.
LOOPscript.jstrueLeft alone, the thread opens and folds again and again.

Try them in the Playground

When to use it

For the comments of a design or review app, for the discussions of a forum or a community, for the replies under an article or a product: wherever a conversation has nested replies to open without losing who answers whom.

On phones

The same animation with adapted sizes: the card is almost as wide as the screen, type and spacing shrink with the height, the branches recompute themselves and a finger opens the replies and votes.

With reduced motion

Nothing moves: the replies appear and disappear with a fade, the branches appear whole, numbers and words change with a fade and the light does not run.

Pitfalls

  • The site's viewer may scale the page down: positions read with getBoundingClientRect must be divided by the thread's scale, or the branches miss the avatars.
  • Animating the height to a number and leaving it there stops a reply opened further down from stretching the list: once open the height goes back to auto.
  • The avatar's ring sticks out 4 pixels and the list is clipped by overflow: the inner content has 6 pixels of padding per side, offset by a negative margin.
  • Branches sharing a trunk overlap: with a transparent colour the trunk would get lighter where two pass, which is why the colour is solid.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 2 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 components