Skip to content
animorio
IT
Back to the library

Blood type compatibility

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

Who can give blood to whom: two rows of eight types, donors above and recipients below. Move over a type and the red lines fan out to every compatible one, a light running along them, while the heading says how many it gives to or receives from.

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>
<!--
  "Blood type compatibility" 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>Blood type compatibility</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">
    <!-- who can give red cells to whom: pick a blood type among the donors or the recipients
         and the lines draw themselves to every compatible type on the other row -->
    <section class="bt" data-bt aria-label="Blood type compatibility">
      <header class="bt__head">
        <b class="bt__type" data-type>O</b>
        <span class="bt__say">
          <span class="bt__tag"><span data-tag>Universal donor</span></span>
          <span class="bt__line"><span data-line>gives to all 8 types</span></span>
        </span>
      </header>

      <div class="bt__board" data-board>
        <span class="bt__label">Donor</span>
        <div class="bt__row" data-row="give" role="group" aria-label="Donor blood type"></div>
        <svg class="bt__wires" data-wires aria-hidden="true"></svg>
        <div class="bt__row" data-row="take" role="group" aria-label="Recipient blood type"></div>
        <span class="bt__label">Recipient</span>
      </div>
    </section>

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

16 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 “Blood type compatibility” 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, at the top a blood type written large in red and two lines beside it: “Universal donor” and “gives to all 8 types”. Below, two rows of eight chips, donors above and recipients below, from O negative to AB positive. At first the chips come in from the two sides and O negative is picked: from its chip, solid red, eight curved lines fan out to all the recipients, the nearest first; a short white light runs along them once and each chip reached lights up in a soft red with a small nudge. Moving over another donor the lines are redrawn from it and the lines at the top roll over: “A+ gives to 2 types”. Moving over a recipient the direction flips: the lines climb to those who can give to it and the words roll the other way, “AB+ receives from all 8 types”. The chips are real buttons: they work by touch and by keyboard.

How it works

The rule in one line

Each type is three bits: A, B and Rh. A donor can give to a recipient if all its bits are also in the recipient’s: (d & r) === d. The lines come from that, with no hand-written table.

Lines from the chips

Each line is a Bézier curve from the middle of the picked chip to the middle of the compatible one, measured with getBoundingClientRect and worked out again on resize. With pathLength 1 it draws by animating stroke-dashoffset.

A fan, then the light

The lines start in order of distance from the picked chip. A second copy of each path, with a short dash, is the light that runs along it as soon as it is drawn.

Values to change

NameFileDefaultWhat it changes
ACCENTscript.js#e5484dThe colour of the blood and the lines.
STARTscript.jsO-The type picked at first among the donors (O-, O+, A-, A+, B-, B+, AB-, AB+).
DRAWscript.js0.55How many seconds a line takes to draw.
STAGGERscript.js0.05The gap between one line and the next, in seconds.
BENDscript.js0.55How much the lines bend (0 = straight, 1 = very soft).
LOOPscript.jstrueLeft alone, a pointer visits a few types.

Try them in the Playground

When to use it

On the site of a blood donor association or a hospital, in a donation campaign, on an explainer or school page; and wherever you must show what is compatible with what: plans and features, devices and accessories, roles and permissions.

On phones

The same scene: the eight chips fit in one row and are tapped one at a time. The lines are worked out again if the screen changes size.

With reduced motion

The lines are already drawn. Picking another type, lines, chips and words change without motion.

Pitfalls

  • The rule is the red cell one (ABO and Rh systems), true in general: for plasma it is the reverse, and a real transfusion is always decided by medical staff with compatibility tests. This is not medical advice.
  • The chips are buttons with aria-pressed and a spelled-out label (“Donor O negative”); the sentence at the top, repeated in the section’s aria-label, gives the result to those who cannot see the lines.
  • The lines are measured from the chips in pixels: if you change the layout, the function that redraws them must be called again, as it already is on resize.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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