HoverFree

Gift Unwrap Reveal

A gift box to click: it spins once, its lid and bow lift off, and a golden tag pops out of the box with a bounce and twelve sparks.

Vanilla JSRevealFestive

Updated

Hover or click the scene to interact

This effect is free — the Hover category contains 49 effects total, including 5 free. Effect.Labs has 846 vanilla effects. Explore the category →

Usage examples

BarsGift boxesWorkshops Basket (0)

One day, one offer

Unwrap today's treat

Every morning until 24 December, a different discount waits in the parcel. It is valid until midnight.

The code is typed in at the basket step.

① Today's offer to unwrap at the top of a chocolate maker's Christmas shop

WhenAt the top of the home page, in the weeks before Christmas: the box takes the left half, the text explains the rule on the right (a different discount every morning, valid until midnight). The visitor clicks the box itself.
WhyThe offer changes every day, so the gesture is worth repeating too. A code shown in plain text would be read in a second; here the visitor waits a second and a half in front of the spinning box, and the tag popping out becomes the most looked-at spot of the page.
Settingsdata-code="PRALINE15". Background and minimum height of .guw-scene removed to set the box on the brown of the page. Box aligned to the bottom of its column and scaled with transform: scale() on .guw-gift: 1.18 on a large screen, 0.72 on a phone.
The Solvène herbalist's letter

One seasonal herbal tea, every first Monday

Thank you! Your welcome gift is opening.

Your welcome gift

② Welcome gift that opens after signing up to a herbalist's newsletter

WhenNext to a sign-up form: the box is there, closed, under the heading “Your welcome gift”. It does not respond to clicks. The “Sign me up” button is what opens it, and the discount code pops out when the sign-up goes through.
WhyThe gift is no longer the thing you click but the answer to another action. While closed, it shows what signing up earns; once open, it confirms it is done, without changing page.
SettingsThe page script calls .click() on the .guw-gift when the form is submitted. Before that, the box is locked with pointer-events: none and tabindex="-1", removed afterwards. data-code="TISANE10", scale 0.9, .guw-hint prompt removed.
Nortavel · Intranet Year-end game

Three parcels, one prize in each. Which one is yours?

Parcel A

Parcel B

Parcel C

One parcel per person · the game closes on Friday at noon

③ Three parcels, one prize in each — year-end game on a company intranet

WhenAn internal game page opened in December: three small boxes in different colours side by side, with a prize written in each (a day off, a food hamper, two cinema seats). Each employee opens one.
WhyThree copies of the effect in the same page, each with its own state: one can be opened without touching the others. The box colours tell the parcels apart, and the tag carries a prize in full words instead of a code.
SettingsThree roots, without data-code: the text of each .guw-code is written in the HTML (no 🎄 added). Scale 0.62, tag font raised to 22 px to stay readable. Box and lid recoloured green and blue through .guw-box and .guw-lid.

How it works

The whole gift is a single 220 × 250 px <button class="guw-gift">. Inside, .guw-inner holds four pieces drawn in CSS: the box (.guw-box), the lid (.guw-lid), the bow (.guw-bow, a 🎀 emoji) and the tag (.guw-code), tucked behind the box and shrunk to 60%. The click does one thing only: it adds or removes the .guw-open class on the button. Everything else is a chain of staggered CSS transitions.

On opening, .guw-inner turns 360° in 0.75 s around a point set at 70% of its height, level with the box. At 0.78 s the lid rises 86 px while tilting 10°, and the bow follows. At 1 s the tag rises 104 px and returns to full size along a curve that overshoots before settling: that is the bounce. At 1.1 s the script adds twelve <span class="guw-spark"> that fan out upwards, 50 to 100 px away, and removes them 0.8 s later.

A second click wraps it again in reverse order, thanks to other delays: the tag goes back at once, the lid drops at 0.55 s, the box spins again at 0.9 s. The tag text comes from data-code on .guw-scene, with a 🎄 in front; without that attribute, the content of .guw-code written in the HTML is kept as is.

Each [data-guw] in the page has its own state: several gifts open separately, and the script adds nothing to window.

Accessibility

  • Screen readers: the drawing of the box is hidden (aria-hidden), and the tag with it. The revealed text therefore travels two other ways: the button's name, which becomes “Gift opened: NOEL30. Activate to wrap it again.”, and an announcement area (role="status") that says “Gift opened: NOEL30” when the tag pops out. Once closed, the button is “Open the gift” again and the announcement is cleared.
  • Keyboard: Tab moves to the box, Enter or Space opens it, the same key closes it. The focus outline (2 px, pink #fb7185) only shows for keyboard use, thanks to :focus-visible.
  • Touch: a finger tap counts as a click, nothing else to plan. The button is 220 × 250 px, far above the minimum size of a touch target.
  • Reduced motion: with prefers-reduced-motion: reduce, the four transitions are cut and the sparks are not created. The box jumps from closed to open, the tag is readable at once and the announcement goes out without waiting.
  • Two limits to know: the tag sits inside a button, so its text cannot be selected with the mouse to copy it; and the “Click to unwrap” prompt is written small, in pink at 60% opacity. If the code has to be typed out, repeat it in plain text in the page once the gift is open.

Browser compatibility

The floor comes from the CSS inset property, which gives .guw-inner its size: Chrome 87, Firefox 66, Safari 14.1. The rest is older: CSS variables for the direction of the sparks (Chrome 49, Firefox 31, Safari 9.1), :focus-visible for the outline (Chrome 86, Firefox 85, Safari 15.4; before that, no outline drawn by the effect). Versions read from @mdn/browser-compat-data.

Chrome 87+✓ Full (measured on Chromium 149: click, keyboard, two gifts, announcement)
Firefox 66+✓ Full (measured on Firefox 151)
Safari 14.1+✓ Full in the WebKit 26.5 test build; real Safari not verified
Edge 87+✓ Not verified (same engine as Chrome)
iOS 14.5+✓ Not verified on a real phone (simulated tap: full)
Android Chrome 87+✓ Not verified on a real phone (simulated tap: full)

Without JavaScript, the box stays closed: it is a button named “Open the gift” that does nothing, and the tag is never shown. Do not rely on it for essential information. In a browser without inset, the pieces of the box pile up on each other.

The code

Copy it all in one click, or block by block. No dependencies.

HTML
<div class="fx-0812-root">
  <div class="guw-scene" data-guw data-code="NOEL30">
    <button type="button" class="guw-gift" data-guw-box aria-label="Open the gift">
      <span class="guw-inner" aria-hidden="true">
        <span class="guw-code" data-guw-code>🎄 NOEL30</span>
        <span class="guw-box"></span>
        <span class="guw-lid"></span>
        <span class="guw-bow">🎀</span>
      </span>
    </button>
    <div class="guw-hint" aria-hidden="true">Click to unwrap</div>
    <p class="guw-status" data-guw-status role="status"></p>
  </div>
</div>
CSS
.fx-0812-root,
.fx-0812-root *,
.fx-0812-root *::before,
.fx-0812-root *::after {
  box-sizing: border-box
}

.fx-0812-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 200px;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.guw-scene {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 330px;
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #241433, #0b0a14 72%);
}

.guw-gift {
  position: relative;
  width: 220px;
  height: 250px;
  border: 0;
  background: none;
  cursor: pointer;
  outline-offset: 8px;
}

.guw-gift:focus-visible {
  outline: 2px solid #fb7185;
  border-radius: 12px;
}

.guw-code {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%) translateY(0) scale(.6);
  z-index: 3;
  background: linear-gradient(135deg, #ffe08a, #f2a900);
  color: #5b3a00;
  font-weight: 800;
  letter-spacing: .06em;
  font-size: 16px;
  padding: 9px 16px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .4);
  border: 2px dashed #b97e00;
  transition: transform .55s cubic-bezier(.2, 1.55, .35, 1);
  transition-delay: 0s;
}

.guw-box {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  width: 140px;
  height: 96px;
  border-radius: 9px;
  z-index: 4;
  background: linear-gradient(135deg, #e01e37, #9c0f20);
  box-shadow: inset 0 -10px 16px rgba(0, 0, 0, .32), 0 14px 22px rgba(0, 0, 0, .4);
}

.guw-box::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 24px;
  height: 100%;
  background: linear-gradient(#ffd166, #f2a900);
}

.guw-box::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 24px;
  background: linear-gradient(90deg, #f2a900, #ffd166);
}

.guw-lid {
  position: absolute;
  left: 50%;
  bottom: 124px;
  transform: translateX(-50%) translateY(0) rotate(0);
  width: 162px;
  height: 40px;
  border-radius: 9px;
  z-index: 6;
  background: linear-gradient(135deg, #f0263f, #b01225);
  box-shadow: 0 6px 12px rgba(0, 0, 0, .35);
  transition: transform .5s cubic-bezier(.34, 1.3, .5, 1);
  transition-delay: .55s;
}

.guw-lid::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: 24px;
  height: 100%;
  background: linear-gradient(#ffd166, #f2a900);
}

.guw-bow {
  position: absolute;
  left: 50%;
  bottom: 150px;
  transform: translateX(-50%) translateY(0);
  font-size: 40px;
  z-index: 7;
  transition: transform .5s cubic-bezier(.34, 1.3, .5, 1);
  transition-delay: .55s;
}

.guw-inner {
  position: absolute;
  inset: 0;
  transform-origin: 50% 70%;
  transition: transform .75s cubic-bezier(.45, .05, .2, 1);
  transition-delay: .9s;
}

.guw-gift.guw-open .guw-inner {
  transform: rotate(360deg);
  transition-delay: 0s;
}

.guw-gift.guw-open .guw-lid {
  transform: translateX(-50%) translateY(-86px) rotate(-10deg);
  transition-delay: .78s;
}

.guw-gift.guw-open .guw-bow {
  transform: translateX(-50%) translateY(-76px) rotate(28deg);
  transition-delay: .78s;
}

.guw-gift.guw-open .guw-code {
  transform: translateX(-50%) translateY(-104px) scale(1);
  transition-delay: 1s;
}

.guw-spark {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffd166;
  z-index: 8;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: guw-spark .75s ease-out forwards;
}

.guw-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #fb7185;
  opacity: .6;
  pointer-events: none;
  transition: opacity .3s;
}

.guw-scene.guw-done .guw-hint {
  opacity: 0;
}

.guw-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {

  .guw-inner,
  .guw-lid,
  .guw-bow,
  .guw-code {
    transition: none !important;
  }
}

@keyframes guw-spark {
  to {
    transform: translate(-50%, -50%) translate(var(--dx), var(--dy)) scale(.2);
    opacity: 0;
  }
}
JavaScript (fx-0812)
(function() {
  /* December 2026 sprint — Christmas — Gift Unwrap Reveal (fx-0812) */
  (function() {
    var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
    /* Texts read by screen readers; {code} = the revealed text */
    var i18n = {
      fr: { open: 'Ouvrir le cadeau', opened: 'Cadeau ouvert : {code}. Activer pour le ré-emballer.', said: 'Cadeau ouvert : {code}' },
      en: { open: 'Open the gift', opened: 'Gift opened: {code}. Activate to wrap it again.', said: 'Gift opened: {code}' }
    };

    document.querySelectorAll('[data-guw]').forEach(function(scene) {
      var gift = scene.querySelector('[data-guw-box]');
      var code = scene.querySelector('[data-guw-code]');
      var status = scene.querySelector('[data-guw-status]'); // announcement area (role="status"), optional
      if (scene.dataset.code) code.textContent = '🎄 ' + scene.dataset.code;
      var open = false,
        sayTimer = 0;

      /* --- language detection: data-lang > closest lang > html > en --- */
      var lang = (scene.getAttribute('data-lang') || (scene.closest('[lang]') || document.documentElement).getAttribute('lang') || 'en').toLowerCase().indexOf('fr') === 0 ? 'fr' : 'en';
      var t = i18n[lang];
      gift.setAttribute('aria-label', t.open);

      function burst() {
        if (reduceMotion) return;
        for (var i = 0; i < 12; i++) {
          var s = document.createElement('span');
          s.className = 'guw-spark';
          s.style.left = '50%';
          s.style.bottom = '150px';
          var a = (i / 12) * 6.2832 + Math.random() * 0.4,
            d = 50 + Math.random() * 50;
          s.style.setProperty('--dx', Math.cos(a) * d + 'px');
          s.style.setProperty('--dy', -Math.abs(Math.sin(a) * d) - 10 + 'px');
          gift.appendChild(s);
          (function(el) {
            setTimeout(function() {
              el.remove();
            }, 800);
          })(s);
        }
      }

      function toggle() {
        open = !open;
        gift.classList.toggle('guw-open', open);
        scene.classList.toggle('guw-done', open);
        /* The gift drawing is hidden from screen readers (aria-hidden): the revealed text goes through the button's name
           and through the announcement area, when it pops out of the box */
        var txt = scene.dataset.code || code.textContent.trim();
        gift.setAttribute('aria-label', open ? t.opened.split('{code}').join(txt) : t.open);
        clearTimeout(sayTimer);
        if (status) {
          if (open) sayTimer = setTimeout(function() {
            status.textContent = t.said.split('{code}').join(txt);
          }, reduceMotion ? 0 : 1100);
          else status.textContent = '';
        }
        if (open) setTimeout(burst, reduceMotion ? 0 : 1100);
      }
      gift.addEventListener('click', toggle);
      gift.addEventListener('keydown', function(e) {
        if (e.key === 'Enter' || e.key === ' ') {
          e.preventDefault();
          toggle();
        }
      });
    });
  })();
})();

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Tag text — data-code on .guw-scene NOEL30 The script writes “🎄” then the value. For another emoji or none, remove data-code and write the text straight into .guw-code.
Box size — transform: scale() on .guw-gift 220 × 250 px The pieces are placed in pixels: for a smaller or larger box, scale the button rather than changing its dimensions. When open, the bow rises about 35 px above the button: keep that margin free.
Box colour — .guw-box and .guw-lid Red, from #e01e37 to #9c0f20 Two gradients to change together, the lid one shade lighter than the box.
Ribbon colour — .guw-box::before, .guw-box::after, .guw-lid::before Gold, #ffd166 and #f2a900 The three bands of the ribbon. The sparks (.guw-spark) and the tag have their own golden colour, to be matched.
Sparks — loop of burst() 12, thrown between 50 and 100 px Change the 12 of the loop (and the one in the division) for the number, and 50 + Math.random() * 50 for the distance.
Spin duration — transition of .guw-inner 0.75 s If you lengthen it, shift the delays of the lid (0.78 s), the tag (1 s) and the two 1100 in the script (sparks and announcement) by the same amount, otherwise the tag will pop out before the spin ends.
Texts read by screen readers — i18n object of the script English or French depending on the page language The script picks from data-lang on .guw-scene, otherwise from the closest lang attribute. For another language or wording, edit the three sentences; {code} is replaced by the revealed text.

FAQ

Can the tag hold something other than a code?

Yes: a first name, a prize, a date, a few words. Write them into .guw-code and remove data-code. Two caveats: the tag does not wrap (white-space: nowrap), so keep it short; and since it sits inside a <button>, it can contain neither a link nor another button.

How do I open the gift from another button?

Call .click() on the .guw-gift: that is what the second example does when the form is submitted. To know whether it is already open, check for the guw-open class. Do not set that class yourself: the button's name and the announcement for screen readers would not follow.

Does a screen reader read the revealed code?

Yes. The drawing is hidden, but the script writes the code into the button's name and announces it in [data-guw-status] when the tag pops out. Keep that paragraph in your HTML: without it, the opening is no longer announced, only the button's name changes.