axi0motion

Tilt card

A card leans toward the pointer in 3D, with a soft glare.

  • enhancer
  • card
  • hover
  • 3d
  • pointer
  • since 0.1

Background Studio: tune it below, then copy the code

Your system asks for reduced motion: the demo shows its final state and nothing moves.

Live demo

Tilt card example

Tilt

The card leans toward the pointer.

Controls

8 deg
1.02
900 px

Code

It follows the controls above: change an option and the code changes with it.

<link rel="stylesheet" href="/axi0/motion/motion.css?v=6">
<script src="/axi0/motion/motion.js?v=10" defer></script>

<div class="demo-card" data-motion="tilt">
  <h4>Tilt</h4>
  <p>The card leans toward the pointer.</p>
</div>

The wrappers: Tilt.tsx (React, TypeScript) and Tilt.vue (Vue). Both render the same attributes as the HTML; the loader does the rest.

Options

AttributeDefaultWhat it does
data-motion-max8the largest lean, in degrees
data-motion-scale1.02how much it grows while leaning
data-motion-perspective900perspective distance in pixels
data-motion-glaretruea soft glare that follows the lean

Accessibility

A short eased loop runs only while the card moves toward its target, then stops. Off for touch and under reduced motion. The script owns the element's transform: put it on a wrapper if the card has its own.

Size

tilt.js is 1.0 KB gzip. A page loads the loader (2.7 KB) and core.js (1.4 KB) once, whatever it uses.