Collapse
v1.0.1Updated 21 Jul 2026Animates its child between zero and its natural size, measuring real content with a ResizeObserver so no fixed height or width is needed. `orientation` switches between collapsing height (accordions) and width (sidebars), and the measurement re-runs when the content changes, so dynamic children stay correct. The only transition wrapper that animates layout rather than opacity or transform.
Preview
Live · 4 stories▸Why this is recommendedcollapseexpandaccordiontransition+7
Collapse — vertical and horizontal.
- ✓Expanding an FAQ or accordion row on click
- ✓Collapsing a filter sidebar to widen the content area
- ✓Showing advanced settings under a 'more options' toggle
- ✓Revealing extra detail rows inside a table or card
- Animates height or width between 0 and natural content size
- Auto-measures content via ResizeObserver — no fixed size needed
- Vertical (accordion) and horizontal (sidebar) orientations
- Re-measures when children change
- Configurable duration / delay / easing per instance
- Respects prefers-reduced-motion (snaps, no animation)
- data-orientation + data-state attributes for debugging
- ✕Simple show / hide with no size change (use Fade)
- ✕Animating opacity or transform only (use Fade, Grow, or Zoom)
- ✕Very long content, where animating height can cost layout performance
Install
Ask your agent, or call the MCP tool directly. The resolved bundle is written into your project.
Usage
Tick variants in the left menu — each adds a tab with that variant’s real story source, the same code the preview above renders.
Props
inWhether the child is expanded; drives the transition
yesorientationCollapse height (vertical) or width (horizontal). Default 'vertical'
—durationDuration in ms. Default 200
—delayDelay in ms before the transition starts. Default 0
—easingTiming function. Default 'ease-out'
—unmountOnExitRemove the child from the DOM after exit. Default false
—classNameExtra classes merged onto the wrapper element
—styleExtra inline styles; transition-driven properties take precedence
—refRef to the outer wrapper element (React 19 ref-as-prop)
—childrenContent to collapse / expand
yes