Skip to content
animorio
IT
Back to the library

Cohort retention chart

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

A dashboard’s cohort retention: each row is who signed up in one week, each column how many were still there later. The triangle fills in a wave along its diagonals; hover a cell and a sprung frame catches it, its row, its column and the diagonal of the same calendar week stay lit, and the percentage and the people count up on top.

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>
<!--
  "Cohort retention chart" 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>Cohort retention chart</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 cohort retention table: each row is the people who signed up in one week, each column how many
         were still there N weeks later; a sprung frame follows the cell being read, with its row,
         its column and the diagonal of the same calendar week -->
    <section class="co" data-co aria-label="Weekly cohort retention">
      <header class="co__head">
        <span class="co__titles">
          <span class="co__name">Retention</span>
          <span class="co__roll co__what"><span data-what></span></span>
        </span>
        <span class="co__read">
          <b class="co__num"><span data-num>0</span><i>%</i></b>
          <span class="co__roll co__who"><span data-who></span></span>
        </span>
      </header>
      <div class="co__grid" data-grid tabindex="0" role="group" aria-label="Retention by cohort and week. Use the arrow keys to read a cell">
        <span class="co__lens" data-lens aria-hidden="true"></span>
      </div>
      <span class="co__say" data-say aria-live="polite"></span>
    </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.

13 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 “Cohort retention chart” 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 warm grey, a white card: “Retention”, below it “Weekly cohorts”, and on the right a large number with its small line. Then the table: weeks W0 to W6 on top, each cohort’s Monday on the left, and a triangle of orange cells, fuller where more people stayed, with the number inside; at the bottom the “Average” row with the means in outlined cells. At first the cells come in as a wave along the diagonals, with a small bounce, and the number on top counts to the average after four weeks. Hover a cell and a dark frame reaches it on a spring, overshooting slightly before it settles; the rest steps back, except its row, its column and, outlined, the diagonal of cells measured in the same calendar week. The number on top counts to that cell’s percentage, the label names cohort and week (“Oct 5 cohort, week 3”) and below how many people that is (“312 of 761 people”); at the bottom that week’s average takes the dark outline. Leave and everything returns. On a keyboard the arrows move the frame.

How it works

The triangle is a grid

The table is a CSS grid with one column for dates and one per week. Newer cohorts have fewer measured weeks: empty cells take their place, and the triangle makes itself.

Colour is the data

Each cell mixes the accent colour with white through color-mix, in proportion to the percentage; past a threshold the number inside turns from dark to white to stay readable.

One frame, on a spring

The frame is a single element above the grid: its position chases the cell being read with a spring integrated on GSAP’s ticker, so between distant cells it speeds up and slightly overshoots the arrival.

Row, column and diagonal

Row and column give the cohort and its age; the diagonal (row plus column equal) is the cells measured in the same calendar week: if a release went wrong, it shows there.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#ee5a2aThe colour of the cells: the fuller, the more people stayed.
WEEKSscript.js7How many weekly cohorts the table shows (4 to 8).
LIFTscript.js1How much newer cohorts improve: 0 = all alike, 2 = a lot.
SNAPscript.js1How elastic the frame following the cell is: 0.3 = stiff, 2 = very elastic.
LOOPscript.jstrueLeft alone, the demo’s pointer reads a few cells and then lets go.

Try them in the Playground

When to use it

In a subscription product’s dashboard, in a monthly investor update, on an analytics tool’s page. The same sprung frame with row, column and diagonal suits any dense table: a timetable, a price matrix, a shift calendar.

On phones

The same card, as wide as the screen, with slightly narrower cells. A finger taps or slides over the table and the cell stays read until another is touched.

With reduced motion

The cells are already in place, the frame jumps to the cell being read with no spring and numbers and labels change without counting or rolling. The demo does not move by itself.

Pitfalls

  • Cohorts, people and percentages are made up: one curve, lifted a little for each newer cohort. A real table takes its data from product events.
  • With a finger, pointerleave fires as soon as it lifts: no return to the average there, or a cell could never be read on a phone.
  • The frame is measured on the real cell with getBoundingClientRect: it must be measured again on resize, since columns are fractions.
  • Week zero is always 100: keeping it helps reading the row, but in the colour scale it would flatten everything else, so the scale starts at 20.

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 20 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