An interactive component which expands/collapses a panel.
Order #4189
StatusShipped
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 Radix UI. Everything else stays the same.
import { Collapsible } from '@animate-ui/react/primitives/radix-ui';
export function Changelog() {
return (
<Collapsible.Root>
<Collapsible.Trigger>Show all changes</Collapsible.Trigger>
<Collapsible.Content>
Drop-in primitives for Radix UI, Base UI and React Aria.
</Collapsible.Content>
</Collapsible.Root>
);
}Coming from the @radix-ui/react-collapsible package? Use the subpath: import * as CollapsiblePrimitive from '@animate-ui/react/primitives/radix-ui/collapsible'.
Animation
- Content unfolds like the accordions: its height grows from 0 while the content fades in from a 2px blur, over 350ms on a soft ease-out. While it moves, its bottom edge fades (over 16px, or over the part still hidden): the content never meets what follows it with a hard cut. It folds back the same way, in reverse, then unmounts.
- Toggling it while it moves retargets from where it is.
- Open by default (
defaultOpen), it animates open on mount (page load), as in v1. --radix-collapsible-content-heightand--radix-collapsible-content-widthreadauto: classes using them follow Motion's height instead of a stale measure.- With
forceMount, closed content stays in the DOM, collapsed andinert. <AnimateUIProvider tempo>paces both transitions.- Under reduced motion, the height changes at once; the fade and the blur still play.
API Reference
Every part takes exactly the props of Radix UI's Collapsible. Animate UI adds the animation props below.
Root, Trigger
Radix UI props only. They are not animated.
Content
Radix UI props, plus:
| Prop | Type | Default |
|---|---|---|
transition? | Transition | { duration: 0.35, ease: [0.215, 0.61, 0.355, 1] } |
exitTransition? | Transition | transition |