For sighted users to preview content available behind a link.
Installation
Install the packages
Add the shadcn-vue component
Animate it
The CLI finds your shadcn-vue components through components.json, swaps their primitive imports for Animate UI's and removes the CSS animation classes Motion replaces.
Usage
<script setup lang="ts">
import {
HoverCardContent,
HoverCardPortal,
HoverCardRoot,
HoverCardTrigger,
} from '@animate-ui/vue/primitives/reka-ui';
</script>
<template>
<HoverCardRoot>
<HoverCardTrigger href="https://animate-ui.com"
>@animate_ui</HoverCardTrigger
>
<HoverCardPortal>
<HoverCardContent :side-offset="4"
>Animated drop-in primitives for Reka UI.</HoverCardContent
>
</HoverCardPortal>
</HoverCardRoot>
</template>Animation
The motion of Animate UI's React Hover Card:
- Content grows from 0.8 and fades in, from the trigger (
--reka-hover-card-content-transform-origin), on a spring (stiffness 400, damping 29) that overshoots a little before it settles. - Once reka-ui's
close-delayis over, it closes the same way: it shrinks back to 0.8 on the same spring while it fades out, then unmounts. - reka-ui only opens it for mouse-like pointers: a tap on a touch screen follows the link, nothing sticks.
- With
force-mount(on the Content or the Portal), the closed content stays in the DOM: it plays its exit, then is hidden andinert. - Reopening while it closes picks up from where it is, on the same spring.
- Open from the start (
default-open), it plays the same entrance on page load. - With
follow-cursoron the Root, the content leans towards the pointer while it moves over the trigger, by half its offset from the trigger's center, on a spring (stiffness 200, damping 17): on both axes, or only'x'or'y'. Under reduced motion it follows without the spring. - Under reduced motion, it only fades (no scale).
API Reference
Every part takes exactly the props of reka-ui's Hover Card. Animate UI adds the animation props below.
HoverCardRoot
reka-ui props, plus:
| Prop | Type | Default |
|---|---|---|
follow-cursor? | boolean | 'x' | 'y' | false |
follow-cursor-spring-options? | SpringOptions | { stiffness: 200, damping: 17 } |
HoverCardTrigger, HoverCardPortal, HoverCardArrow
reka-ui props only. They are not animated.
HoverCardContent
reka-ui props, plus:
| Prop | Type | Default |
|---|---|---|
transition? | Transition | { type: 'spring', stiffness: 400, damping: 29 } |
exit-transition? | Transition | transition |