Skip to the content

Depth tilt

A card with depth. Under the pointer the card turns in perspective to face it, on a spring: a small angle, a heavy brake, nothing that wobbles.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    A layer does not grow as it slides: a picture that exactly fills the surface needs a little more size than its box, or an edge shows. And the default sheen is white, so a white card wants a dark sheenColor.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-depth-tilt Marks a card: the box that keeps still, takes the pointer and carries the settings. It takes no value: leave the value field empty. Put it on any box of the page, as many as you like; each one tilts on its own.
    data-depth-tilt-surface On the box inside the card that turns, usually one div that fills it. It takes no value. Without it the card turns itself, and shivers when the pointer sits on its very edge. [ Optional ]
    data-depth-tilt-layer On anything inside the card that should float, with a number as its value: 1 slides one step of the depth setting towards the pointer, 3 three steps, and a negative number sinks the layer under the sheet so it slides the other way. Empty reads as 1. Without any layer the card turns in one piece. [ Optional ]
    data-depth-tilt-state Written by the engine on the card: live while it is turned or moving, idle at rest, still under reduced motion. Never written by hand. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-depth-tilt-sheen-color #ffffff Colour of the disc of light that follows the pointer over the surface. Options: any CSS colour, white on a dark or coloured card, a dark ink on a white one; taken out of this block, --depth-tilt-sheen-color on the card takes over.
    data-depth-tilt-sheen 0.3 Strength of the sheen at its centre, 0 to 1.
    data-depth-tilt-angle 7 Tilt of the card, in degrees, when the pointer is on one of its edges.
    data-depth-tilt-perspective clamp(700px, 70vw, 1200px) Distance from the eye to the card, any CSS unit: how strongly the far edge shrinks as the card turns.
    data-depth-tilt-depth clamp(4px, 0.45vw, 8px) Distance a layer of depth 1 slides when the pointer is on an edge, any CSS unit; each layer multiplies it by its own number.
    data-depth-tilt-scale 1.02 Size of the card while the pointer holds it, in times its own size.
    data-depth-tilt-stiffness 120 Pull of the spring towards the pointer.
    data-depth-tilt-damping 14 Brake on that pull; with stiffness it sets how much the card overshoots.

What it does

Depth tilt is a cursor animation for Webflow and vanilla JavaScript, with no library. Also called parallax tilt card, 3D tilt card or 3D card hover effect.

A card with depth. Under the pointer the card turns in perspective to face it, on a spring: a small angle, a heavy brake, nothing that wobbles. Any element inside marked with a depth and a number slides by its own amount, so the picture, the title and the label come apart as if they sat at different heights over the sheet, and a layer with a negative number sinks under it and slides the other way. A soft disc of light follows the pointer across the surface. On leave everything goes back to flat with a little overshoot, and the inline values the tilt wrote are taken away, so a card at rest is the stylesheet's own. Any number of cards on a page share one loop, which only runs while a card moves. On touch a card follows the finger while it presses and settles when it lifts. No picture to load, no canvas, no library: transforms on the page's own elements.

Updated

Questions

Add three custom attributes to your own elements: data-depth-tilt on the card, which keeps still and takes the pointer, data-depth-tilt-surface on the box inside it that turns, and data-depth-tilt-layer="2" on anything inside the surface that should float. Settings go on the card, for instance data-depth-tilt-angle="10".

No. There is no library, no canvas and no picture to load: the engine writes CSS 3D transforms on the page's own elements and moves them on a damped spring. Any number of cards on a page share one loop, which only runs while a card moves.

Set data-depth-tilt-angle, the tilt of the card in degrees when the pointer is on one of its edges, 7 by default. Under 4 the turn is felt more than seen; past 12 the card swings like a toy and its far edge visibly shrinks. data-depth-tilt-perspective sets how strongly that far edge shrinks.

Each element marked data-depth-tilt-layer slides by depth, clamp(4px, 0.45vw, 8px) by default, times its own number. 1 is one step towards the eye, 0 keeps the layer on the sheet, and a negative number sinks it under the sheet so it slides the other way. A layer does not grow, so a picture that exactly fills the surface needs a negative inset to have picture left to slide in.

Yes. On touch a card follows the finger while it presses and settles when the finger lifts, and the page still scrolls: a press that turns into a scroll is cancelled by the browser. Under prefers-reduced-motion there is no tilt, no slide and no scale, and the sheen alone fades in at the middle of the card.