Displays rich content in a portal, triggered by a button.
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 {
PopoverContent,
PopoverPortal,
PopoverRoot,
PopoverTrigger,
} from '@animate-ui/vue/primitives/reka-ui';
</script>
<template>
<PopoverRoot>
<PopoverTrigger>Open popover</PopoverTrigger>
<PopoverPortal>
<PopoverContent :side-offset="4"
>Place content for the popover here.</PopoverContent
>
</PopoverPortal>
</PopoverRoot>
</template>Animation
The motion of Animate UI's React Popover:
- Content grows from 0.8 and fades in, from the trigger (
--reka-popover-content-transform-origin, set inline so it works without styles), on a spring (stiffness 400, damping 29) that overshoots a little before it settles, by ~440ms. - It closes the same way: it shrinks back to 0.8 on the same spring while it fades out, then unmounts.
- Opening from the keyboard animates the same way. Focus goes back to the trigger once the exit is over.
- 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. - Under reduced motion, it only fades (no scale).
API Reference
Every part takes exactly the props of reka-ui's Popover. Animate UI adds the animation props below.
PopoverRoot, PopoverTrigger, PopoverAnchor, PopoverPortal, PopoverClose, PopoverArrow
reka-ui props only. They are not animated.
PopoverContent
reka-ui props, plus:
| Prop | Type | Default |
|---|---|---|
transition? | Transition | { type: 'spring', stiffness: 400, damping: 29 } |
exit-transition? | Transition | transition |