Cloth unveil card: pull the cover off your newest item

Grab the cloth over the bakery card and drag it up: the hem rises fastest where you hold it, waves ripple along the edge, and the new galette appears underneath.

A bakery has a new seasonal galette, a salon has a new treatment, a shop has stock that arrives on Friday. On most websites the news sits in a card that looks exactly like last month's card, and people scroll past it. A cloth unveil card hides the new item under a draped cover with a gold hem. Pull the cloth up, or just tap it, and it lifts away in folds to show what is new.

New this week

Maple pear galette

Butter pastry, local pears and a maple glaze, baked every morning from Friday to Sunday.

$7.50 a slice or $38 for the whole galette

Drag the cloth upward or tap it. On a keyboard, press Enter or Space.

Live demo. It runs on exactly the code further down this page.

How it works

  1. Real content first. The card underneath is ordinary HTML: a heading, a short description, a price and a button. While the cloth is on, the content has the inert attribute so nobody can tab into a hidden button.
  2. A cloth made of strips. The cover holds a canvas. Each frame it paints 48 thin vertical strips in slightly different greens, which reads as folds, and draws a gold line along the bottom edge as the hem.
  3. The hem follows the hand. Dragging upward raises the cloth. The part closest to where you grabbed rises faster, and a small wave runs along the hem, so it looks pulled rather than slid.
  4. Let go and it decides. Past about a third of the way, the cloth finishes lifting by itself. Below that it drops back with a little sway. A small spring handles both, and the animation stops completely once the cloth settles.
  5. Tap and keys work too. The cover is a real button, so a tap, Enter or Space lifts the cloth all the way. Once it is off, focus moves to the new item's heading and a live region says what was revealed.

The code

Three blocks, no libraries, nothing loaded from anywhere else.

HTML
<div class="cu" data-lab="cloth-unveil">
  <div class="cu-card">
    <div class="cu-content" inert>
      <div class="cu-art" aria-hidden="true"><span class="cu-pie"></span></div>
      <p class="cu-kicker">New this week</p>
      <h3 class="cu-title" tabindex="-1">Maple pear galette</h3>
      <p class="cu-text">Butter pastry, local pears and a maple glaze, baked every morning from Friday to Sunday.</p>
      <p class="cu-price">$7.50 a slice <span>or $38 for the whole galette</span></p>
      <button class="cu-cta" type="button">Reserve a slice</button>
    </div>
    <button class="cu-cover" type="button" aria-describedby="cu-help">
      <canvas class="cu-cloth" aria-hidden="true"></canvas>
      <span class="cu-tag"><span>Something new is under here</span><b>Pull the cloth up</b></span>
    </button>
  </div>
  <p id="cu-help" class="cu-help">Drag the cloth upward or tap it. On a keyboard, press Enter or Space.</p>
  <p class="cu-status" aria-live="polite"></p>
  <button class="cu-again" type="button" hidden>Cover it again</button>
</div>
CSS
.cu {
  display: grid;
  justify-items: center;
  gap: 12px;
  font-family: system-ui, sans-serif;
  color: #101a14;
}
.cu-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  border: 1px solid #c9cec4;
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}
.cu .cu-content { padding: 0 22px 22px; text-align: left; }
.cu-art {
  display: grid;
  place-items: center;
  height: 140px;
  margin: 0 -22px 16px;
  background: radial-gradient(circle at 50% 120%, #f4d96c 0, #f8ecb8 45%, #fbf6e2 70%);
}
/* A simple drawn galette: pastry ring with fruit in the middle. */
.cu-pie {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle, #c9792f 0 30%, #e8b45c 31% 58%, #b8742c 60% 70%, #d99a48 71%);
  box-shadow: 0 8px 18px rgba(16, 26, 20, .18);
}
.cu .cu-card .cu-content .cu-kicker { margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #46534a; }
.cu .cu-card .cu-content .cu-title { margin: 0 0 8px; padding: 0; font: 700 22px/1.2 system-ui, sans-serif; letter-spacing: normal; color: #133621; outline: none; }
.cu .cu-card .cu-content .cu-text { margin: 0 0 12px; font-size: 15px; line-height: 1.5; color: #46534a; }
.cu .cu-card .cu-content .cu-price { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
.cu .cu-card .cu-content .cu-price span { display: block; font-size: 13px; font-weight: 400; color: #46534a; }
.cu-cta, .cu-again {
  border: 0;
  border-radius: 999px;
  font: 600 15px/1 system-ui, sans-serif;
  cursor: pointer;
}
.cu-cta { width: 100%; height: 46px; background: #133621; color: #f4d96c; }
.cu-again { height: 40px; padding: 0 18px; background: transparent; color: #133621; box-shadow: inset 0 0 0 1px #c9cec4; }
.cu-cta:focus-visible, .cu-again:focus-visible { outline: 3px solid #f4d96c; outline-offset: 3px; }
.cu-cover {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: #133621;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.cu-cover:active { cursor: grabbing; }
.cu-cover:focus-visible { outline: 3px solid #f4d96c; outline-offset: -6px; }
.cu-cover.is-drawn { background: transparent; }
.cu-cloth { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.cu-tag {
  position: absolute;
  left: 0;
  right: 0;
  top: 42%;
  display: grid;
  gap: 6px;
  padding: 0 20px;
  text-align: center;
  color: #f2f3ef;
  font-size: 14px;
  pointer-events: none;
}
.cu-tag b { font-size: 20px; color: #f4d96c; }
.cu-help { margin: 0; max-width: 340px; font-size: 14px; color: #46534a; text-align: center; }
.cu-status { min-height: 1.4em; margin: 0; font-size: 15px; font-weight: 600; color: #133621; text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .cu-cover { transition: opacity .3s; }
}
JavaScript
(function () {
  var root = document.querySelector('[data-lab="cloth-unveil"]');
  if (!root) return;
  var cover = root.querySelector('.cu-cover');
  var canvas = root.querySelector('.cu-cloth');
  var tag = root.querySelector('.cu-tag');
  var content = root.querySelector('.cu-content');
  var title = root.querySelector('.cu-title');
  var again = root.querySelector('.cu-again');
  var status = root.querySelector('.cu-status');
  var ctx = canvas.getContext('2d');
  var calm = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
  var STRIPS = 48;        // vertical strips the cloth is drawn from
  var LET_GO = 0.35;      // lifted past this share, the cloth finishes on its own
  var w = 0, h = 0, lift = 0, target = 0, speed = 0, grabX = 0.5;
  var raf = 0, dragging = false, startY = 0, moved = 0, wobble = 0;

  function size() {
    var r = cover.getBoundingClientRect(), dpr = Math.min(window.devicePixelRatio || 1, 2);
    w = r.width; h = r.height;
    canvas.width = Math.round(w * dpr); canvas.height = Math.round(h * dpr);
    ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
    draw(0);
  }

  function ease(t) { return t * t * (3 - 2 * t); }

  // The bottom edge of the cloth at a point across the card (f from 0 to 1).
  // The part near the grab point rises first, and small waves ripple along the hem.
  function hem(f, t) {
    var near = Math.exp(-Math.pow((f - grabX) / 0.28, 2));
    var col = Math.min(1, lift * (1 + 0.7 * near * (1 - lift)));
    var wave = 7 * Math.sin(f * 17 + t * 0.006) * Math.sin(Math.PI * lift);
    return h - (h + 30) * ease(col) + wave + wobble * Math.sin(f * 13 + t * 0.012);
  }

  function draw(t) {
    ctx.clearRect(0, 0, w, h);
    var sw = w / STRIPS, i, f, x, fold, ys = [];
    for (i = 0; i <= STRIPS; i++) ys.push(hem(i / STRIPS, t));
    for (i = 0; i < STRIPS; i++) {
      f = (i + 0.5) / STRIPS;
      // Folds: light and dark bands that bunch up a little as the cloth rises.
      fold = 0.5 + 0.5 * Math.sin(f * (20 + lift * 14) + lift * 5);
      ctx.fillStyle = 'rgb(' + Math.round(16 + 26 * fold) + ',' + Math.round(46 + 50 * fold) + ',' + Math.round(28 + 32 * fold) + ')';
      x = i * sw;
      ctx.beginPath();
      ctx.moveTo(x - 0.5, 0); ctx.lineTo(x + sw + 0.5, 0);
      ctx.lineTo(x + sw + 0.5, ys[i + 1]); ctx.lineTo(x - 0.5, ys[i]);
      ctx.fill();
    }
    // Gold hem with a soft shadow under it.
    ctx.beginPath();
    for (i = 0; i <= STRIPS; i++) ctx[i ? 'lineTo' : 'moveTo'](i * sw, ys[i]);
    ctx.lineWidth = 8; ctx.strokeStyle = 'rgba(16,26,20,.18)';
    ctx.save(); ctx.translate(0, 5); ctx.stroke(); ctx.restore();
    ctx.lineWidth = 3; ctx.strokeStyle = '#f4d96c'; ctx.stroke();
    tag.style.opacity = Math.max(0, 1 - lift * 3);
    cover.classList.add('is-drawn');
  }

  // A small spring moves the cloth toward its target and stops when it settles.
  function frame(t) {
    if (!dragging) {
      speed = (speed + (target - lift) * 0.09) * 0.8;
      lift += speed;
    }
    wobble *= 0.95;
    draw(t);
    var still = Math.abs(target - lift) < 0.002 && Math.abs(speed) < 0.002 && wobble < 0.3;
    if (!dragging && still) {
      raf = 0; lift = target; wobble = 0; draw(t);
      if (target === 1) reveal();
      return;
    }
    raf = requestAnimationFrame(frame);
  }

  function run() { if (!raf) raf = requestAnimationFrame(frame); }

  function lifting() {
    if (calm) { lift = 1; reveal(); return; }
    target = 1; run();
  }

  function reveal() {
    var hadFocus = document.activeElement === cover;
    cover.hidden = true;
    content.removeAttribute('inert');
    again.hidden = false;
    status.textContent = 'Revealed: maple pear galette, new this week.';
    if (hadFocus) title.focus();
  }

  function coverAgain() {
    lift = target = speed = wobble = 0;
    cover.hidden = false;
    content.setAttribute('inert', '');
    again.hidden = true;
    status.textContent = 'Covered again.';
    size();
    cover.focus();
  }

  cover.addEventListener('pointerdown', function (e) {
    if (calm) return;
    cover.setPointerCapture(e.pointerId);
    var r = cover.getBoundingClientRect();
    grabX = (e.clientX - r.left) / r.width;
    dragging = true; startY = e.clientY; moved = 0;
    run();
  });
  cover.addEventListener('pointermove', function (e) {
    if (!dragging) return;
    moved = Math.max(moved, Math.abs(startY - e.clientY));
    lift = Math.max(0, Math.min(1, (startY - e.clientY) / (h * 0.8)));
  });
  function release() {
    if (!dragging) return;
    dragging = false; speed = 0;
    if (lift > LET_GO) { target = 1; }
    else if (lift > 0.02) { target = 0; wobble = 6; }
    run();
  }
  cover.addEventListener('pointerup', release);
  cover.addEventListener('pointercancel', release);
  // A tap or a key press counts as "lift it for me". A real drag is handled above.
  cover.addEventListener('click', function () { if (moved < 6) lifting(); });
  cover.addEventListener('keydown', function () { moved = 0; });
  again.addEventListener('click', coverAgain);

  if (window.ResizeObserver) new ResizeObserver(function () { if (!cover.hidden) size(); }).observe(cover);
  else window.addEventListener('resize', size);
  size();
})();

When to use it, and when not to

It works for one item you want people to notice: a new menu dish, a seasonal product, a launch, a prize in a giveaway, a new location announcement. The small act of pulling something off feels like opening a present, and it gives the item a moment that a plain card does not. It also suits a page people visit on purpose, such as a "what's new" section or an event page.

It is a poor fit for anything people need quickly. Opening hours, prices, contact details and booking buttons should never be hidden behind a gesture. Do not cover more than one card per page either: the second unveil is a chore, not a surprise. And keep in mind that some people will never interact with it, so the text around the card should still say what the new item is. Search engines read the content underneath, because it is normal HTML.

For accessibility, the cover has a clear name and instructions, works with the keyboard, and reduced motion settings skip the animation and simply show the card. On phones the cover stops the page from scrolling while a finger is on it, so keep the card a sensible height.

Make it yours

  • Cloth colour: the two sets of numbers in the ctx.fillStyle line set the darkest and lightest fold. The hem colour is the #f4d96c value right after it.
  • How easy it is to pull: raise LET_GO to make people pull further before the cloth finishes on its own, or lower it for a lighter touch.
  • Fold detail: STRIPS sets how many strips make up the cloth. More strips look smoother; 30 to 60 is plenty for a card.

Frequently asked questions

Can people still read what is under the cloth without lifting it?

Screen readers and search engines can read the text, because it is regular HTML. Only the interactive parts are blocked with inert until the cloth comes off.

Does the cloth come back when the page is reloaded?

Yes. Nothing is stored, so every visit starts covered. If you want it to stay open for returning visitors, that would need a small change to remember the choice.

Will it slow my page down?

No. The canvas only draws while someone is pulling or the cloth is settling, then the animation loop stops. When idle it costs nothing.

What should your website do?

Describe a feature you wish your site had. If it is useful to other owners too, we build it here as a free Lab post with a live demo and code.

We never publish your name, email or website. Privacy

More from the Website Lab

All experiments
Effects

Scratch card reveal with canvas

Drag to scratch off a foil and reveal a hidden message, built with one canvas. Works on touch screens, with a keyboard friendly reveal button.

3 min read