Skip to content
animorio
IT
All components

Payment failed banner

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

The notice of a subscription whose payment was declined: the card icon on red, what happened, the attempts already made and “Retry now”. On tap a line runs along the bottom edge while the button says “Charging $29.00”; when the payment goes through, the notice turns green, the card in the icon gives way to a tick drawing itself and the third attempt lights up.

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>
<!--
  "Payment failed banner" 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>Payment failed banner</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">
    <!-- the failed payment notice of a subscription: the attempts made so far, Retry now running the
         new charge along the bottom edge, and the payment going through with its tick -->
    <section class="pf" data-pf data-state="failed" role="status" aria-label="Billing notice">
      <div class="pf__top">
        <span class="pf__icon" aria-hidden="true"><svg viewBox="0 0 22 22"><g data-card><rect x="2.500" y="5" width="17" height="12" rx="2.600"></rect><path d="M2.500 9.200h17"></path></g><path class="pf__tick" data-tick pathLength="1" d="m6.200 11.400 3.300 3.300 6.400-7.200"></path></svg></span>
        <div class="pf__text">
          <strong class="pf__title"><span data-outtitle>Payment failed</span></strong>
          <p class="pf__body"><span data-outbody>Your card ending 4821 was declined. We’ll try again on 2 December.</span></p>
        </div>
      </div>
      <div class="pf__tries"><span class="pf__bars" aria-hidden="true"><i data-try class="is-bad"></i><i data-try class="is-bad"></i><i data-try></i></span><span class="pf__count"><span data-outcount>Attempt 2 of 3</span></span></div>
      <div class="pf__actions">
        <button class="pf__main" type="button" data-retry><span class="pf__face" data-face="retry">Retry now</span><span class="pf__face" data-face="busy">Charging $29.00</span><span class="pf__face" data-face="done">Done</span></button>
        <button class="pf__link" type="button" data-update>Update card</button>
      </div>
      <i class="pf__run" data-run aria-hidden="true"></i>
    </section>
    <span class="live" aria-live="polite" data-live></span>

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

16 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 “Payment failed banner” 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 white, a rounded notice with a pinkish ground and a red edge: on the left a red tile with a card icon, which wobbles for a moment on entering; next to it “Payment failed” and the sentence “Your card ending 4821 was declined. We’ll try again on 2 December.”. Below, three dashes, two red and one empty, with “Attempt 2 of 3”, and at the bottom the dark “Retry now” button and the “Update card” link. Tapping “Retry now” rolls the title into “Trying again”, the sentence says who is being asked for the money and what for, the count goes to “Attempt 3 of 3”, the button shows “Charging $29.00” and a dark line runs along the notice’s bottom edge. When the line ends the payment goes through: ground, edge and icon tile turn green, the card shrinks and the tick draws itself in its place while the tile bounces, the third dash lights up green, the title becomes “Payment received” with the renewal date, “Update card” disappears and the button says “Done”.

How it works

Three states, one attribute

Declined, in progress and paid are one attribute on the notice: from it come the colour of the ground, the edge and the icon. The texts of the three states live in a single object and all roll together.

The line of the attempt

The new attempt is a line at the bottom of the notice going from zero to the full width: when it ends it calls the successful payment. In a real app the server’s answer is what ends it.

From card to tick

Card and tick live in the same svg, one on top of the other. The card shrinks around the centre of the drawing and fades, the tick draws itself with stroke-dashoffset and the tile bounces.

Values to change

NameFileDefaultWhat it changes
BADscript.js#d9432fThe colour of the notice and of the failed attempts.
GOODscript.js#128a5eThe colour of the successful payment.
CHARGEscript.js1.7How many seconds the new attempt lasts.
SPRINGscript.js1How much the icon and the button bounce.

Try them in the Playground

When to use it

At the top of the account or billing page of a subscription service, when a renewal did not go through; the same notice with its “retry” carries a failed send, an interrupted backup, a failed sync or a document that did not upload.

On phones

The notice is at most 340 pixels wide and about 190 tall, and narrows with the screen: the sentence wraps by itself and always keeps two lines of room, so the height does not jump between states. Button and link are 44 pixels tall.

With reduced motion

No running line: after the attempt’s wait the notice fades to green, with the tick already drawn and the texts changing without rolling. The icon does not wobble. The demo’s pointer does not start.

Pitfalls

  • The notice is a status region and every step is read out in an aria-live region: whoever cannot see the colour hears “Payment received”.
  • The state is not told by red and green alone: the title, the sentence, the icon and the attempt count all change.
  • During the attempt the button is really disabled, so a double tap cannot start two charges.
  • Card, amounts and dates are invented and the outcome is decided by the script: in a real product it comes from the payment provider, and can also be another decline.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

Tested on 28 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 components