March 12, 2021 • 2 min read
The payment form on our website looks a little bit dull. Customers get bored and don’t input their card details. How can we make it more engaging?
We are going to use Vanilla-tilt.js to make our card move in 3 dimensions when hovering it with our mouse or tilting our handheld device.
It is really simple:
npm install vanilla-tilt
or import it from a CDN as in the example:
import vanillaTilt from "https://cdn.skypack.dev/vanilla-tilt@1.7.0";
const card = document.querySelector("#card");
VanillaTilt.init(card, { max: 10, speed: 1000, perspective: 700 });
And that’s really it! Here is our final result: