A card that tilts in 3D toward the pointer.
Installation
Usage
<script setup lang="ts">
import { Tilt, TiltContent } from '@animate-ui/vue/primitives/effects/tilt';
</script>
<template>
<Tilt :max-tilt="10">
<TiltContent class="rounded-2xl border p-4">
<img src="/mug.webp" alt="Mug" />
<h3>Matt Mug</h3>
</TiltContent>
</Tilt>
</template>Tilt tracks the pointer and sets the perspective; TiltContent is the part that rotates.
Animation
- The content rotates up to
max-tiltdegrees toward the pointer on a spring, and flattens back when it leaves. - The rotation is driven by motion values: moving the pointer never re-renders Vue.
- Under reduced motion, the content stays flat.
API Reference
Tilt
| Prop | Type | Default |
|---|---|---|
as-child? | boolean | false |
max-tilt? | number | 10 |
perspective? | number | 800 |
transition? | SpringOptions | { stiffness: 300, damping: 25, mass: 0.5 } |
...props? | HTMLMotionProps<'div'> | - |
TiltContent
| Prop | Type | Default |
|---|---|---|
as-child? | boolean | false |
...props? | HTMLMotionProps<'div'> | - |