Esc

Try “tilt”, “reveal”, “drag”, or “reduced motion”.

Start

Introduction

Kinesis makes elements react to the pointer, scroll, and touch. You set CSS variables, it animates them with springs.

Kinesis is a 14 KB library for interactive motion. Cards tilt toward the pointer, buttons lean in, lists appear on scroll, panels drag and throw. You declare the behavior in CSS, and Kinesis does the measuring, animating, and cleanup.

.card {
  --k-tilt: 12deg;
  --k-motion: soft;
}
New

Depth, not decoration

Each layer sits at its own height above the card.

Move your pointer over the stageEdit

The idea

Kinesis properties are CSS variables with registered types. The browser computes their values, so media queries, :hover, calc(), em, and design tokens work in them.

Values move on springs. A spring keeps its speed when its target changes, so motion that follows the pointer never jumps. --k-motion sets how it feels.

Setup

  1. Add data-kinesis to a container. Kinesis looks for animated elements inside it and measures the pointer against it.
  2. Give elements a Kinesis property, such as --k-tilt or --k-when.
  3. Call initKinesis() once. Elements added later are picked up.
<section class="hero" data-kinesis>
  <img class="hero__art" src="art.png" alt="">
</section>

<style>
  .hero__art { --k-parallax: 24px; }
</style>

<script type="module">
  import { initKinesis } from "@amineyarman/kinesis"
  initKinesis()
</script>

What it does

Pointer effects move an element based on where the pointer is: parallax, tilt, magnetic, repel, follow, look, point, and spin.

Reactions animate between two states on a trigger: the pointer coming near, hover, press, scrolling into view, or scroll position. --k-when sets the trigger. Outputs like --k-scale set what changes.

Drag makes an element draggable, with bounds and throwing. See Drag.

All three combine on one element, in CSS or in JavaScript.

What it doesn't do

Timelines and keyframe sequences. CSS animations, the Web Animations API, and GSAP handle those, and they run alongside Kinesis on the same elements.

Next: Getting started.

Edit this page on GitHub