useCollapse

Animate the height of an element when it opens and closes.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

Spread the style and onTransitionEnd on the element that grows and shrinks.

APIs

useCollapse

const useCollapse = <T extends HTMLElement = HTMLElement>(options: {
  opened: boolean
  duration?: number
}) => {
  ref: RefObject<T | null>
  style: CSSProperties
  onTransitionEnd: () => void
}
Edit this page on GitHub