An accessible popup anchored to a button.
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 the primitive from Animate UI instead of Base UI. Everything else stays the same.
import { Popover } from '@animate-ui/react/primitives/base-ui/popover';
export function SharePopover() {
return (
<Popover.Root>
<Popover.Trigger>Share</Popover.Trigger>
<Popover.Portal>
<Popover.Positioner sideOffset={4}>
<Popover.Popup>
<Popover.Title>Share this document</Popover.Title>
<Popover.Description>
Anyone with the link can view it.
</Popover.Description>
<Popover.Close>Done</Popover.Close>
</Popover.Popup>
</Popover.Positioner>
</Popover.Portal>
</Popover.Root>
);
}Using the @base-ui/react umbrella import instead? The barrel mirrors it: import { Popover } from '@animate-ui/react/primitives/base-ui'.
Animation
The motion of Animate UI v1's Base UI Popover, value for value:
- Popup grows from 0.8 and fades in, from the trigger (
--transform-origin), 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.
- The Portal keeps Base UI's portal mounted while the popup exits; Base UI waits for the exit before it hides the positioner, and
onOpenChangeCompletefires once it's over. - Opening from the keyboard animates the same way.
- With
keepMountedon the Portal, the closed popup stays in the DOM: it plays its exit, then is hidden. - Your own
renderelement (or function) on the Popup is made animatable rather than replaced. - Reopening while it closes picks up from where it is, on the same spring.
- Open from the start (
defaultOpen), it plays the same entrance on page load, like v1. - Under reduced motion, it only fades (no scale).
API Reference
Every part takes exactly the props of Base UI's Popover. Animate UI adds the animation props below.
Root, Trigger, Portal, Positioner, Arrow, Backdrop, Title, Description, Close, Viewport
Base UI props only. They are not animated.
Popup
Base UI props, plus:
| Prop | Type | Default |
|---|---|---|
transition? | Transition | { type: 'spring', stiffness: 400, damping: 29 } |
exitTransition? | Transition | transition |