A preview of the content behind a link, shown on hover. Built with React Aria's PreviewTrigger and Popover.
Installation
Install the packages
Add the shadcn/ui component
Animate it
The CLI finds your shadcn/ui components through components.json, swaps their primitive imports for Animate UI's and removes the CSS animation classes Motion replaces.
Usage
Import from Animate UI instead of react-aria-components: it re-exports all of React Aria, with an animated Popover. Everything else stays the same.
import {
Link,
Popover,
PreviewTrigger,
} from '@animate-ui/react/primitives/react-aria';
export function ProfileLink() {
return (
<PreviewTrigger>
<Link href="https://github.com/imskyleen/animate-ui">@animate-ui</Link>
<Popover placement="bottom" offset={4}>
Animated drop-in primitives for Radix UI, Base UI and React Aria.
</Popover>
</PreviewTrigger>
);
}Animation
React Aria has no Animate UI v1 counterpart: under a PreviewTrigger, the Popover moves like v1's Hover Card.
- Popover grows from 0.8 and fades in, from the link (
--trigger-anchor-point), on a spring (stiffness 400, damping 29) that overshoots a little before it settles. - Once the trigger's close delay is over, it closes the same way: it shrinks back to 0.8 on the same spring while it fades out, then unmounts.
- Moving straight from one preview to the next during
PreviewTrigger's warmup swaps them without animation, as React Aria intends (shouldSkipAnimation). - React Aria opens it on hover for pointer input, after a delay on keyboard focus, and on a long press: nothing sticks on touch screens.
- Open from the start (
defaultOpenon thePreviewTrigger), it plays its entrance on page load, like v1. - Under reduced motion, it only fades (no scale).
API Reference
Popover takes exactly the props of React Aria's Popover, plus:
| Prop | Type | Default |
|---|---|---|
transition? | Transition | { type: 'spring', stiffness: 400, damping: 29 } |
exitTransition? | Transition | transition |
PreviewTrigger and Link take React Aria props only. They are not animated.