Skip to content
animorio
IT
Back to the library

Margin comments

Text, HoverGSAP, CSS onlyMediumCompressed weight: Demo 8.0 KBGSAP 28 KBFreeDownload the zip

A post on Slowpost, a made-up blog, where every paragraph keeps its readers’ comments in the margin: a small speech bubble with the count. Point at a paragraph and the others step back while its bubble lifts; touch the bubble and a highlighter sweeps across the sentence the readers quoted while the comments slide out beside it, one after another, with the quote in italics on top. Like a comment and the heart swells and the number rolls; answer and the new comment drops in at the bottom while the bubble in the margin counts one more. On a phone the comments rise from the bottom as a sheet.

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>
<!--
  "Margin comments" 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 blog post with readers' comments in the margin of each paragraph</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/opsz-italic.css">
  <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 post on Slowpost, a made-up blog: every paragraph keeps its readers' comments in the margin, as a small
         bubble with the count. Point at a paragraph and the others step back; touch the bubble and the sentence the
         readers quoted gets highlighted while the comments slide out beside it. You can like a comment and add yours. -->
    <article class="post" data-post>
      <header class="post__top">
        <span class="brand">
          <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 5.5h12M4 10h8M4 14.5h10" /></svg>
          Slowpost
        </span>
        <span class="post__meta">Essay · 6 min read</span>
      </header>

      <h1 class="post__title">The year I stopped <em>answering</em> emails</h1>
      <p class="post__by"><span class="av av--small" style="--c:#e7d3c3">NK</span> Noa Kessler · 12 Nov</p>

      <div class="post__body">
        <div class="par" data-par="0">
          <p>For twelve months I read my inbox once a week, on Friday morning, with a coffee and a timer. <span class="hl" data-hl>Nothing urgent ever waited longer than a phone call.</span></p>
          <button class="bub" type="button" data-bub aria-label="2 responses to this paragraph">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 4.5h12a1.5 1.5 0 0 1 1.5 1.5v6.5a1.5 1.5 0 0 1-1.5 1.5H9l-3.6 2.6V14H4a1.5 1.5 0 0 1-1.5-1.5V6A1.5 1.5 0 0 1 4 4.5Z" /></svg>
            <span class="bub__n" data-n>2</span>
          </button>
        </div>
        <div class="par" data-par="1">
          <p>The surprise was not the quiet. <span class="hl" data-hl>It was how many questions had answered themselves by Friday,</span> and how few people noticed I was slow.</p>
          <button class="bub" type="button" data-bub aria-label="14 responses to this paragraph">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 4.5h12a1.5 1.5 0 0 1 1.5 1.5v6.5a1.5 1.5 0 0 1-1.5 1.5H9l-3.6 2.6V14H4a1.5 1.5 0 0 1-1.5-1.5V6A1.5 1.5 0 0 1 4 4.5Z" /></svg>
            <span class="bub__n" data-n>14</span>
          </button>
        </div>
        <div class="par" data-par="2">
          <p>I still keep the timer. <span class="hl" data-hl>Twenty minutes, then the laptop closes,</span> whatever is left can wait for next week.</p>
          <button class="bub" type="button" data-bub aria-label="5 responses to this paragraph">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 4.5h12a1.5 1.5 0 0 1 1.5 1.5v6.5a1.5 1.5 0 0 1-1.5 1.5H9l-3.6 2.6V14H4a1.5 1.5 0 0 1-1.5-1.5V6A1.5 1.5 0 0 1 4 4.5Z" /></svg>
            <span class="bub__n" data-n>5</span>
          </button>
        </div>
      </div>

      <!-- the comments of the chosen paragraph -->
      <aside class="panel" data-panel aria-hidden="true" aria-label="Responses">
        <div class="panel__head">
          <span class="panel__title"><span data-ptotal>14</span> responses</span>
          <button class="close" type="button" data-close aria-label="Close responses">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9" /></svg>
          </button>
        </div>
        <blockquote class="quote" data-quote>It was how many questions had answered themselves by Friday,</blockquote>
        <ul class="list" data-list></ul>
        <form class="reply" data-reply autocomplete="off">
          <span class="av av--small" style="--c:#d9e4dc">YO</span>
          <input class="reply__in" data-input type="text" placeholder="Add a response" aria-label="Your response">
          <button class="reply__go" type="submit" data-send disabled>Post</button>
        </form>
      </aside>
    </article>

    <svg class="ghost" data-ghost viewBox="0 0 24 24" aria-hidden="true"><path d="M5 3.2 19.2 11l-6.3 1.6-3.3 5.9Z"></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.

40 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 “Margin comments” 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 paper coloured background there is a post from Slowpost: the header with the three line logo, the title in Newsreader with a terracotta italic word, the byline with an avatar and three paragraphs. In the right margin of each paragraph there is a drawn speech bubble with the number of comments (2, 14, 5). The post rises in line by line and the bubbles pop in with a small bounce. Pointing at a paragraph dims the others gently while its bubble lifts two pixels and swells a little. Touch the bubble and it turns terracotta on a pink ground; a pink highlighter sweeps left to right across the sentence the readers quoted, and the comments panel slides in from the right with a long ease: the number of responses and the close button on top, the quoted sentence in italics with a terracotta rule below, then the comments one after another, with the avatars popping in and the heart with the likes. Touch a heart and it fills, swells and settles while the number rolls up. At the bottom the Add a response field: typing lights up Post, and the new comment opens up at the bottom while the panel count and the bubble count in the margin both roll on by one. The close button or Esc close it all: the panel slides back, the highlighter withdraws, the paragraphs light up again. On a phone the panel rises from the bottom as a sheet. Left alone, a drawn pointer reads, opens the paragraph with fourteen comments, likes one, answers and closes.

How it works

The paragraph and its bubble

Each paragraph is a position: relative container and the bubble is an absolutely positioned button in the right margin, outside the text, so the lines never move. The quoted sentence is a span with a gradient background zero wide: the highlighter is only background-size going from 0% to 100%.

The others step back

On pointerenter GSAP takes the other paragraphs to DIM opacity and lifts the bubble with back.out; while the panel is open the chosen paragraph stays lit and the others dimmed.

The panel sliding out

The panel lives inside the article, absolutely positioned: on a computer it comes from xPercent 104 to 0 with expo.out, on a phone from yPercent 104, like a sheet. Quote, comments and field come after it, staggered, and the avatars pop in with a little bounce.

The number that rolls

Likes and responses share one function: the old number rises and fades, the text changes, the new one comes up from below with back.out. The new comment opens with its height growing from zero and clearProps at the end.

Values to change

NameFileDefaultWhat it changes
SLIDE_TIMEscript.js0.75How many seconds the comments panel takes to slide out.
STAGGERscript.js0.07The delay between one comment and the next as they come in.
DIMscript.js0.38How much the other paragraphs dim while you look at one (1 = not at all).
HIGHLIGHT_TIMEscript.js0.6How many seconds the highlighter takes to sweep across the quoted sentence.
LIKE_POPscript.js1.4How much the heart swells when you like a comment.
TYPE_SPEEDscript.js0.04Seconds per letter when the autopilot types the reply.
REPLYscript.js"Friday inbox is the best habit I picked up this year."The reply the autopilot types.

Try them in the Playground

When to use it

On a personal blog, a newsletter published on the web, an online magazine or product documentation: wherever readers discuss one precise sentence rather than the whole piece, and a reader wants to see at once where the conversation gathers.

On phones

Below 560 pixels the panel becomes a sheet rising from the bottom, almost four fifths of the article tall; the bubbles stay in the margin, narrower, and the type is sized on the screen height too.

With reduced motion

No movement or bounces: the panel fades in, the highlighter is already there, the numbers change without rolling; the drawn pointer is hidden.

Pitfalls

  • The panel sits inside the article with overflow: hidden, so on a phone the sheet never leaves the box.
  • The highlighter is background-size on an inline span: it works across line breaks, unlike a pseudo element.
  • One attribute per element: two equal data-post attributes made querySelector grab the article instead of the button.

Libraries

GSAP 3.15.0, Newsreader (font variabile) 5.3.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 14 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