Motion Collapsible Content
Animated container that expands and collapses its content
Overview
Motion Collapsible Content smoothly expands and collapses a region of content, animating both its height and opacity. It animates to the content’s natural height, so content that changes size is always shown in full, and content that is open when the page loads does not grow into place.
Its open state is fully controlled through the isOpen prop — pair it with your own trigger (such as a Button) that toggles the state. Use it for show/more panels, expandable rows, and inline disclosure sections. It is built on Motion, so the animation respects the transition timing defined by the component.
Usage
Import the component:
tsx
import { MotionCollapsibleContent } from "@eqtylab/equality";Drive isOpen from state and toggle it with a trigger:
tsx
const [isOpen, setIsOpen] = useState(false);
<Button onClick={() => setIsOpen((open) => !open)}>Toggle</Button>
<MotionCollapsibleContent isOpen={isOpen}>
<p>Content revealed when open.</p>
</MotionCollapsibleContent>;Default
Props
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
isOpen | Whether the content is expanded. Toggling it animates the change. | boolean | — | ✅ |
children | The content to reveal when open. | ReactNode | — | ✅ |
className | Additional CSS classes applied to the animated container. | string | — | ❌ |