Back to the library

Thread — new messages wait below

Variant: New below

The rule this one is built on: never move what someone is reading. The reader is scrolled up in history when two messages land below, and nothing in view so much as shifts — the arrivals happen off-screen and the only thing that changes is a pill rising in the bottom corner, 216ms from 8px below on ease-out, docked clear of where the rows’ text runs so the notice never covers what it is a notice about. The count rolls rather than repaints, one leaving upward as two arrives from below, inside a fixed-width tabular digit box so the pill never resizes under the eye. The scroll stays the reader’s: only when the pill is pressed does it leave, in 144ms because exits run faster than entrances, with the press folded into the exit so tap and dismissal read as one gesture. The list then glides three rows down in 576ms on ease-in-out and lands on an unread rule drawn in the gap above the first new row, so arriving says where "new" began. Reach for it in chat, activity feeds and live logs, anywhere content appends while someone might be reading above it.

transitionscrolllistcounterindicatorloop

The source

A complete HTML document. Paste it into an empty .html file and it plays — no stylesheet, script, font, or image to fetch.

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Thread — new messages wait below</title>
    <style>
      :root {
        /* Neutrals — fixed, never remixed. */
        --ivory: #faf9f5;
        --paper: #ffffff;
        --oat: #e3dacc;
        --slate: #141413;

        /* Knobs — the remix API. A knob exists iff declared here and used below. */
        --hue: 38.8;
        --lift: 0;
        --chroma: 1;
        --round: 1;
        --speed: 1;

        /* Accents — derived from the knobs with the family's offsets baked in,
           so one hue roll moves them together. Defaults reproduce the original hex. */
        --clay: oklch(calc(0.6724 + var(--lift)) calc(0.1308 * var(--chroma)) var(--hue));
        --clay-d: oklch(calc(0.5797 + var(--lift)) calc(0.127 * var(--chroma)) var(--hue));
        --olive: oklch(
          calc(0.6118 + var(--lift)) calc(0.0713 * var(--chroma)) calc(var(--hue) + 88.3)
        );
        --rust: oklch(
          calc(0.5408 + var(--lift)) calc(0.1357 * var(--chroma)) calc(var(--hue) - 10.3)
        );

        /* Clock — 7.2s, so 1% is 72ms. A message lands below at 14% and
           another at 34%; the pill is pressed at 52%, the list glides 55% to
           63%, and the view resets behind a fade from 86%. */
        --cycle: 7.2s;
        --t: calc(var(--cycle) / var(--speed));

        --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
        --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

        --_muted: color-mix(in srgb, var(--slate) 58%, transparent);
        --_a: color-mix(in srgb, var(--clay) 30%, var(--paper));
        --_j: color-mix(in srgb, var(--olive) 32%, var(--paper));
        --_m: color-mix(in srgb, var(--oat) 90%, var(--paper));
        --_row: 28px;
        --_gap: 6px;
        --_pitch: calc(var(--_row) + var(--_gap));
      }

      * {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
      }

      body {
        min-height: 100vh;
        display: grid;
        place-items: center;
        background: var(--ivory);
        font-family:
          system-ui,
          -apple-system,
          'Segoe UI',
          Roboto,
          sans-serif;
        color: var(--slate);
      }

      .card {
        width: min(340px, 92vw);
        background: var(--paper);
        border: 1px solid var(--oat);
        border-radius: calc(14px * var(--round));
        overflow: hidden;
      }

      .head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        height: 32px;
        padding: 0 14px;
        font-size: 12px;
        color: var(--_muted);
        border-bottom: 1px solid var(--oat);
      }

      .head b {
        color: var(--slate);
        font-weight: 600;
      }

      .view {
        position: relative;
        height: calc(5 * var(--_pitch) - var(--_gap) + 16px);
        padding: 8px 10px;
        overflow: hidden;
      }

      .strip {
        position: relative;
        display: grid;
        gap: var(--_gap);
        animation: strip var(--t) infinite;
      }

      .row {
        display: flex;
        align-items: center;
        gap: 8px;
        height: var(--_row);
        padding: 0 6px;
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
      }

      .av {
        flex: none;
        display: grid;
        place-items: center;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        font-size: 11px;
        font-style: normal;
        font-weight: 600;
        background: var(--_m);
      }
      .a .av {
        background: var(--_a);
      }
      .j .av {
        background: var(--_j);
      }

      .row b {
        flex: none;
        font-weight: 600;
      }

      .row span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        color: var(--_muted);
      }

      /* The unread rule sits in the gap above the first new row, so when the
         reader does go down they land on a line that says where "new" began. */
      .rule {
        position: absolute;
        left: 0;
        right: 0;
        top: calc(6 * var(--_pitch) - var(--_gap) / 2);
        height: 1px;
        background: var(--clay);
      }

      .rule::after {
        content: 'New';
        position: absolute;
        right: 0;
        top: -7px;
        padding: 0 4px;
        font-size: 11px;
        font-weight: 600;
        line-height: 14px;
        color: var(--clay-d);
        background: var(--paper);
      }

      /* Docked to the corner, clear of where the rows' text runs, so the
         notice of new content never covers the content being read. */
      .dock {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 10px;
        display: flex;
        justify-content: flex-end;
        padding-right: 14px;
        pointer-events: none;
      }

      .pill {
        display: flex;
        align-items: center;
        gap: 5px;
        height: 26px;
        padding: 0 10px 0 12px;
        border-radius: 999px;
        font-size: 12px;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
        color: var(--paper);
        background: var(--slate);
        opacity: 0;
        transform-origin: 100% 100%;
        animation: pill var(--t) infinite;
      }

      /* One fixed-width digit box: the count changes and the pill does not
         resize under the reader's eye. */
      .n {
        position: relative;
        width: 1ch;
        height: 15px;
        overflow: hidden;
      }

      .n i {
        position: absolute;
        inset: 0;
        font-style: normal;
        line-height: 15px;
      }

      .n1 {
        animation: n1 var(--t) infinite;
      }
      .n2 {
        opacity: 0;
        transform: translateY(100%);
        animation: n2 var(--t) infinite;
      }

      .pill svg {
        width: 12px;
        height: 12px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
      }

      /* Nothing in the list moves while the reader is up here. The arrivals
         happen off-screen and the only thing that changes in view is the
         pill — the reader decides when to go, and the scroll is theirs. */
      @keyframes strip {
        0%,
        55% {
          opacity: 1;
          transform: translateY(0);
          animation-timing-function: var(--ease-in-out);
        }
        63%,
        86% {
          opacity: 1;
          transform: translateY(calc(-3 * var(--_pitch)));
          animation-timing-function: var(--ease-out);
        }
        90% {
          opacity: 0;
          transform: translateY(calc(-3 * var(--_pitch)));
        }
        90.1% {
          opacity: 0;
          transform: translateY(0);
          animation-timing-function: var(--ease-out);
        }
        95%,
        100% {
          opacity: 1;
          transform: translateY(0);
        }
      }

      /* In over 216ms from 8px below, out over 144ms: exit faster than
         enter. The press is folded into the exit so tap and dismissal read
         as one gesture. */
      @keyframes pill {
        0%,
        14% {
          opacity: 0;
          transform: translateY(8px) scale(0.96);
          animation-timing-function: var(--ease-out);
        }
        17%,
        52% {
          opacity: 1;
          transform: none;
          animation-timing-function: var(--ease-out);
        }
        54% {
          opacity: 1;
          transform: scale(0.96);
          animation-timing-function: var(--ease-out);
        }
        56%,
        100% {
          opacity: 0;
          transform: translateY(6px) scale(0.96);
        }
      }

      /* The count rolls rather than repaints: 1 leaves upward as 2 arrives
         from below, the direction numbers go when they climb. */
      @keyframes n1 {
        0%,
        34% {
          opacity: 1;
          transform: none;
          animation-timing-function: var(--ease-out);
        }
        36.8%,
        96% {
          opacity: 0;
          transform: translateY(-100%);
        }
        96.1%,
        100% {
          opacity: 1;
          transform: none;
        }
      }
      @keyframes n2 {
        0%,
        34% {
          opacity: 0;
          transform: translateY(100%);
          animation-timing-function: var(--ease-out);
        }
        36.8%,
        96% {
          opacity: 1;
          transform: none;
        }
        96.1%,
        100% {
          opacity: 0;
          transform: translateY(100%);
        }
      }

      @media (prefers-reduced-motion: reduce) {
        /* The pill fades in and out in place, the digit crossfades, and the
           list dips out at the history and back in at the latest instead of
           gliding. Everything runs 1.5x. */
        :root {
          --t: calc(var(--cycle) * 1.5 / var(--speed));
        }

        .strip {
          animation-name: strip-still;
        }
        .pill {
          animation-name: pill-still;
        }
        .n1 {
          animation-name: n1-still;
        }
        .n2 {
          transform: none;
          animation-name: n2-still;
        }

        @keyframes strip-still {
          0%,
          55% {
            opacity: 1;
            transform: translateY(0);
          }
          58% {
            opacity: 0;
            transform: translateY(0);
          }
          58.1% {
            opacity: 0;
            transform: translateY(calc(-3 * var(--_pitch)));
          }
          62%,
          86% {
            opacity: 1;
            transform: translateY(calc(-3 * var(--_pitch)));
          }
          90% {
            opacity: 0;
            transform: translateY(calc(-3 * var(--_pitch)));
          }
          90.1% {
            opacity: 0;
            transform: translateY(0);
          }
          95%,
          100% {
            opacity: 1;
            transform: translateY(0);
          }
        }
        @keyframes pill-still {
          0%,
          14% {
            opacity: 0;
          }
          17%,
          54% {
            opacity: 1;
          }
          56%,
          100% {
            opacity: 0;
          }
        }
        @keyframes n1-still {
          0%,
          34% {
            opacity: 1;
          }
          36.8%,
          96% {
            opacity: 0;
          }
          96.1%,
          100% {
            opacity: 1;
          }
        }
        @keyframes n2-still {
          0%,
          34% {
            opacity: 0;
          }
          36.8%,
          96% {
            opacity: 1;
          }
          96.1%,
          100% {
            opacity: 0;
          }
        }
      }
    </style>
  </head>
  <body>
    <div
      class="card"
      role="img"
      aria-label="A reader scrolled up in a channel's history; two new messages arrive below without moving anything in view, a pill rises from the bottom edge counting one then two new, and when it is pressed the pill leaves and the list glides down to an unread rule above the new messages"
    >
      <div class="head"><b># launch</b><span>4 members</span></div>
      <div class="view">
        <div class="strip" aria-hidden="true">
          <div class="row a"><i class="av">A</i><b>Ana</b><span>Ship the beta Friday?</span></div>
          <div class="row m"><i class="av">M</i><b>Mei</b><span>Docs are nearly done</span></div>
          <div class="row j"><i class="av">J</i><b>Joel</b><span>QA is on it today</span></div>
          <div class="row a"><i class="av">A</i><b>Ana</b><span>Changelog draft is up</span></div>
          <div class="row m"><i class="av">M</i><b>Mei</b><span>Screens are exported</span></div>
          <div class="row j"><i class="av">J</i><b>Joel</b><span>Reviewing it now</span></div>
          <div class="row a"><i class="av">A</i><b>Ana</b><span>Pricing page is live</span></div>
          <div class="row m"><i class="av">M</i><b>Mei</b><span>QA signed off</span></div>
          <div class="rule"></div>
        </div>
        <div class="dock" aria-hidden="true">
          <div class="pill">
            <span class="n"><i class="n1">1</i><i class="n2">2</i></span>
            <span>new</span>
            <svg viewBox="0 0 12 12"><path d="M6 2.5v7M2.8 6.6 6 9.6l3.2-3" /></svg>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>