Skip to content
animorio
IT
All components

Loan slider

Sliders, Hover, PhysicsGSAP, CSS onlyMediumCompressed weight: Demo 9.6 KBGSAP 28 KBFreeDownload the zip

The personal loan card of an invented bank, on black: the slider is a ruler of thin ticks. Under the handle the ticks rise as if under a lens, the ones on the left light up mint green, the handle snaps to every 500 euro on a measured spring and a pool of light follows it, mirrored on the card’s top edge too. Amount, monthly payment, interest and the button roll digit by digit, the principal and interest bar splits again, and Continue checks the offer and confirms it with a check.

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>
<!--
  "Loan slider" 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>The loan slider that works out the monthly payment</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" data-stage>
    <!-- the loan card of an invented lender. The slider is a ruler of thin ticks: the ticks under the handle rise
         like under a lens, the ones on the left light up, the handle snaps to every 500 euro on a spring and the
         monthly payment, the interest and the button work themselves out again, digit by digit -->
    <section class="card" data-card aria-label="Personal loan">
      <span class="card__edge" data-edge aria-hidden="true"></span>

      <header class="head">
        <span class="logo" aria-hidden="true">
          <svg viewBox="0 0 24 24"><path d="M5 15.5c3.2 0 4.4-7 7-7s3.8 7 7 7"></path><path d="M5 19h14"></path></svg>
        </span>
        <span class="head__text">
          <span class="head__title">Personal loan</span>
          <span class="head__meta">Selvo · pre-approved</span>
        </span>
        <span class="chip" data-chip>6.9% APR</span>
      </header>

      <p class="ask">How much do you need?</p>
      <p class="amount" data-amountwrap><span class="roll" data-amount></span></p>

      <div class="slider" data-slider role="slider" tabindex="0" aria-label="Loan amount"
           aria-valuemin="1000" aria-valuemax="25000" aria-valuenow="8500" aria-valuetext="8,500 euro">
        <div class="ruler" data-ruler>
          <span class="ruler__pool" data-pool aria-hidden="true"></span>
          <div class="ruler__ticks" data-ticks aria-hidden="true"></div>
          <span class="ruler__base" aria-hidden="true"><span class="ruler__lit" data-lit></span></span>
          <span class="handle" data-handle aria-hidden="true"><span class="handle__knob" data-knob><span class="handle__grip"></span></span></span>
        </div>
        <div class="scale" data-scale aria-hidden="true"></div>
      </div>

      <dl class="stats">
        <div class="stat">
          <dt>Monthly</dt>
          <dd class="stat__big"><span class="roll" data-monthly></span></dd>
        </div>
        <div class="stat">
          <dt>Term</dt>
          <dd data-term></dd>
        </div>
        <div class="stat stat--end">
          <dt>Interest</dt>
          <dd><span class="roll" data-interest></span></dd>
        </div>
      </dl>

      <div class="split" aria-hidden="true">
        <span class="split__a" data-splita></span>
        <span class="split__b" data-splitb></span>
      </div>

      <button class="go" type="button" data-go>
        <span class="go__shine" data-shine aria-hidden="true"></span>
        <span class="go__label" data-golabel>Continue with <span class="roll" data-goamount></span></span>
        <span class="go__wait" data-gowait aria-hidden="true"><svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="8"></circle></svg>Checking your offer</span>
        <span class="go__done" data-godone aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9" pathLength="1"></path></svg>Offer reserved</span>
      </button>
      <p class="sr" aria-live="polite" data-live></p>
    </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.

31 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 “Loan slider” 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 there is the dark personal loan card of Selvo, an invented bank: at the top the mark, Personal loan, pre-approved and the pill with the rate, 6.9% APR. Below the question How much do you need? and the big amount, 8,500 euro. The slider is a ruler of 49 thin ticks, one every 500 euro and a taller one every 5,000, with the scale underneath. Dragging, the silver handle widens and the amount widens with the font’s width axis; the ticks near the handle rise as if under a lens, the ones on its left light up mint green, a pool of light follows it and the light also runs along the card’s top edge. The handle snaps to every 500 euro on a spring that overshoots by a hair: the tick it reaches gives a small jump and the handle a one pixel nod. Amount, the monthly payment over 36 months, interest and the button amount roll digit by digit, up when they grow and down when they shrink, and the thin principal and interest bar splits again. Continue presses in, checks the offer with a light running across it, turns green and draws the check with Offer reserved, then comes back.

How it works

The pull towards the tick

The finger moves a raw value; the target is that value pulled towards the nearest multiple of STEP: the distance, divided by half a step, is raised to 1 plus SNAP times 5. Near the tick it squashes almost to zero, halfway it jumps to the next tick: that is the snap.

The spring

The handle does not go to the target but chases it with a real spring on the GSAP ticker, acceleration equal to STIFFNESS times the distance minus DAMPING times the velocity, with the time step capped at 1/30 of a second. At 340 and 30 it overshoots by a hair and settles.

The lens on the ticks

On every frame each tick rises by LENS times a Gaussian of its distance from the handle, LENS_WIDTH pixels wide, with scaleY from the bottom. The tick just reached gets a knock that fades fast. When nothing moves the loop stops writing.

The payment and the digits

The payment is the one of a fixed-rate loan, P times r over 1 minus (1 plus r) to the minus n, with r the monthly rate. Every character sits in a window one line high: the old one leaves, the new one comes in with back.out, slightly late from right to left.

Values to change

NameFileDefaultWhat it changes
STARTscript.js8500The starting amount, in euro.
MIN_AMOUNTscript.js1000The lowest loan amount, in euro.
MAX_AMOUNTscript.js25000The highest loan amount, in euro.
STEPscript.js500Every how many euro the handle snaps to a tick.
APRscript.js6.9The yearly rate, in percent.
MONTHSscript.js36The length of the loan, in months.
SNAPscript.js0.75How hard the ticks pull the handle: 0 free, 1 a hard snap.
STIFFNESSscript.js340The stiffness of the handle’s spring: higher, quicker.
DAMPINGscript.js30The damping of the spring: lower, more bounce.
LENSscript.js2.1How much the ticks under the handle rise.
LENS_WIDTHscript.js34How wide the lens that lifts the ticks is, in pixels.
ACCENTscript.js#5ef0b0The colour of the light, the lit ticks and the principal share.

Try them in the Playground

When to use it

In a loan or mortgage simulator, in a bank or fintech app, in a form to apply for financing, anywhere an amount is picked between a minimum and a maximum and the monthly cost should show at once.

On phones

The card takes the width of the box minus the margins, the vertical gaps shrink with the height and the ruler measures itself again at its real width. With a finger the handle drags as with the mouse, without scrolling the page.

With reduced motion

No spring, lens, jumps or rolling digits: the handle goes straight to the tick, the ticks on the left light up, the digits change in place and Continue goes straight to the check. The autopilot does not start.

Pitfalls

  • The spring works in fractions of the track and not in euro: so STIFFNESS and DAMPING give the same motion even when the minimum and maximum are changed in the Playground.
  • The digits roll only when the tick under the handle changes, not on every frame of the spring: otherwise during the overshoot the digits would go back and forth.
  • With 49 ticks the loop writes scaleY only when it changes by more than two thousandths and stops completely when the handle and the jumps are still.

Libraries

GSAP 3.15.0, Mona Sans (font variabile) 5.3.0.

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

Testing

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