Skip to content
animorio
IT
All components

Ebook highlight page

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

One page of a reading app, on warm paper lit by a window, like a Dribbble shot: press on a word and drag, and a blue selection follows the finger word by word between two thin handles. On release a small dark menu springs up with four highlighter colours, a note and copy; pick a colour and the marker runs over the sentence line by line, the highlight count rolls up by one and the footer says ‘Saved to Highlights’ with a check that draws itself.

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>
<!--
  "Ebook highlight page" 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 book page in the ebook app with the sentence you highlight</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/mona-sans@5.3.0/wdth.css">
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource-variable/newsreader@5.3.0/index.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <main class="stage">
    <span class="stage__window" aria-hidden="true"><span data-window></span></span>
    <!-- one page of a reading app on warm paper: drag a finger over a sentence and a soft selection follows it word by
         word between two thin handles; let go and a small dark menu springs up with four marker colours. Pick one and
         the marker runs over the sentence, the highlight count in the header rolls up and the footer says it is saved -->
    <div class="book" data-book>
    <span class="book__page book__page--2" aria-hidden="true"></span>
    <span class="book__page" aria-hidden="true"></span>
    <article class="rd" data-reader aria-label="Reading The Salt Orchard, chapter Low Tide">
      <span class="rd__sheen" data-sheen aria-hidden="true"></span>
      <header class="rd__head">
        <span class="rd__cover" aria-hidden="true">
          <span class="rd__cover-title"></span>
          <span class="rd__cover-line"></span>
          <span class="rd__cover-sun"></span>
        </span>
        <span class="rd__book">
          <span class="rd__title">The Salt Orchard</span>
          <span class="rd__author">Ines Marlow · Low Tide</span>
        </span>
        <button class="rd__marks" type="button" data-marks aria-label="Highlight the last sentence">
          <svg viewBox="0 0 24 24" aria-hidden="true">
            <path class="rd__marker-body" d="M14.6 4.4l5 5-8.3 8.3-5-5z"/>
            <path class="rd__marker-tip" data-tip d="M6.3 12.7l5 5-2.3 2.3H4.6l-.6-.6v-4.4z"/>
            <path class="rd__marker-cap" d="M14.6 4.4l1.6-1.6a1.4 1.4 0 0 1 2 0l3 3a1.4 1.4 0 0 1 0 2l-1.6 1.6"/>
          </svg>
          <span class="rd__count" aria-hidden="true"><span data-count>13</span><span data-count>14</span></span>
        </button>
      </header>
      <section class="rd__body">
        <p class="rd__chapter">Low Tide</p>
        <div class="rd__text" data-text>
          <div class="hl" data-hl aria-hidden="true"></div>
          <p class="rd__para" data-para></p>
          <span class="handle handle--a" data-handle aria-hidden="true"></span>
          <span class="handle handle--b" data-handle aria-hidden="true"></span>
        </div>
      </section>
      <footer class="rd__foot">
        <span class="rd__rail" aria-hidden="true"><span class="rd__fill"></span></span>
        <span class="rd__meta">
          <span class="rd__status">
            <span class="rd__line" data-line>p. 212 of 331</span>
            <span class="rd__line rd__line--saved" data-line>
              <svg viewBox="0 0 16 16" aria-hidden="true"><path data-ok pathLength="1" d="M3.4 8.4l3 3 6.2-6.6"/></svg>
              <span data-saved-text>Saved to Highlights</span>
            </span>
          </span>
          <span class="rd__left">11 min left in chapter</span>
        </span>
      </footer>
      <div class="pop" data-pop role="toolbar" aria-label="Highlight">
        <span class="pop__face">
          <button class="pop__sw" type="button" data-sw="0" aria-label="Amber"><span></span></button>
          <button class="pop__sw" type="button" data-sw="1" aria-label="Sage"><span></span></button>
          <button class="pop__sw" type="button" data-sw="2" aria-label="Rose"><span></span></button>
          <button class="pop__sw" type="button" data-sw="3" aria-label="Sky"><span></span></button>
          <span class="pop__rule" aria-hidden="true"></span>
          <button class="pop__act" type="button" data-note aria-label="Add a note">
            <svg viewBox="0 0 20 20" aria-hidden="true"><path d="M4 5.2h12M4 9.4h12M4 13.6h7"/></svg>
          </button>
          <button class="pop__act" type="button" data-copy aria-label="Copy">
            <svg viewBox="0 0 20 20" aria-hidden="true"><rect x="7" y="7" width="9" height="9" rx="2"/><path d="M13 4.6V4a1.6 1.6 0 0 0-1.6-1.6H5.6A1.6 1.6 0 0 0 4 4v5.8a1.6 1.6 0 0 0 1.6 1.6h.6"/></svg>
          </button>
        </span>
        <span class="pop__notch" aria-hidden="true"></span>
      </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.

29 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 “Ebook highlight page” 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 beige table lit by a window, with the soft shadow of the window frame falling across it and a very fine grain, lies a page of warm paper with round corners and the edges of two more pages underneath. At the top the small teal cover of ‘The Salt Orchard’ with the title, the author and the chapter ‘Low Tide’, and on the right the highlights button: a drawn marker with a yellow tip and the number 13. Below, a paragraph in a serif typeface and at the bottom a thin line showing how far you have read, ‘p. 212 of 331’ and ‘11 min left in chapter’. A soft light follows the pointer over the paper. On its own, the page sets its two thin blue handles at the start of the last sentence and the blue selection runs word by word to the full stop, then a small dark menu springs up over the sentence with a notch pointing at it: four little colour squares (amber, sage, rose, sky), a rule, the note and copy. Amber gets a ring, sinks under the finger and comes back; the menu and the handles go, the highlighter runs over each line from left to right with the uneven ends of the felt, the words darken a hair, the marker tip in the button takes the chosen colour, 13 rolls into 14 and the footer swaps the page number for ‘Saved to Highlights’ with a green check that draws itself. After a while the highlight melts away and the loop starts again. With a finger you can select any part of the text, backwards too, and pick the colour; the button at the top selects the last sentence from the keyboard as well.

How it works

One word, one span

The paragraph is written by the script, one word per span. measure() reads with getBoundingClientRect where each word sits in the text block and which line it belongs to; it reads again on every resize through a ResizeObserver, so the bars follow the words when they wrap somewhere else.

Bars under the words

The highlight is a layer under the paragraph with one bar per line: the words on the same line join into one rectangle, and the last word is covered only as far as needed, so the end of the selection can sit halfway through a word. The script places the bar, its child is what GSAP scales.

An end that chases the finger

The end of the selection is a decimal number (word plus fraction) brought to the word under the finger by gsap.quickTo in 0.16 s: the selection does not jump from word to word but glides over them, and the handles follow. Dragging before the anchor, the start goes to the finger and the end stays put.

The menu where there is room

On release the menu sits above the first line, centred on the sentence and kept inside the page; if there is no room above it goes under the last line and the notch flips. The notch follows the sentence's centre through a CSS variable, which is also the origin of the spring the menu opens on.

The marker

Once a colour is picked, a second layer of bars with uneven ends (a border-radius with different horizontal and vertical radii) and mix-blend-mode: multiply opens line by line with scaleX from the left, each line in a time proportional to its length; the counter rolls with two figures in a window and the footer swaps its line with a check drawn by strokeDashoffset.

Values to change

NameFileDefaultWhat it changes
PASSAGEscript.jsThe orchard had gone quiet by the time …The words on the page.
QUOTEscript.jsSome things you learn to love before you understand them.The sentence the page highlights by itself: it has to be in the text.
PICKscript.js0The colour the walk picks: 0 amber, 1 sage, 2 rose, 3 sky.
SWEEPscript.js1.5How many seconds the selection takes to run over the sentence.
FOLLOWscript.js0.16How long the end of the selection takes to catch the finger.
SPRINGscript.js1How springy the menu and the handles are.
HOLDscript.js3.2How many seconds the highlight stays in the walk.
SAVEDscript.js13The highlights the book already has.
AUTOscript.jstrueHighlights by itself until someone touches the page.

Try them in the Playground

When to use it

For a reading or ebook app, a long form articles platform, a blog or a newsletter where people save sentences, a study app: the gesture of highlighting made pleasant, with a clear confirmation of what was saved.

On phones

The same page with adapted sizes: the paper is as wide as the box, the text and the margins shrink with the height too, the selection is made with a finger (the text does not scroll the page while dragging) and the menu always stays inside the paper.

With reduced motion

Nothing slides or bounces: the selection, the menu, the highlight, the counter and the footer fade in, already in place; the light on the paper stays still.

Pitfalls

  • Clearing a selection with a fade, the final callback also deleted the bars of a new selection started in the meantime: now the old bars are detached from the layer at once and remove themselves.
  • Text you can drag a finger over scrolls the page on a phone: the text block has touch-action: none and user-select: none, and the gesture uses setPointerCapture.
  • The words wrap at different points at every width: the positions are read again through a ResizeObserver and the bars and the menu are redrawn.

Libraries

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

Compressed with gzip, the three demo files weigh 11 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