Skip to main content

Mount

Simple mount/unmount helpers with animation delay support.

import { Mount, MountMinimal } from '@gentleduck/primitives/mount'
import { Mount, MountMinimal } from '@gentleduck/primitives/mount'

Mount

A simple component that mounts children when open is true and unmounts after animationDuration when open becomes false.

PropTypeDefaultDescription
openboolean--Whether to show children
renderOncebooleanfalseUnmount completely after close (no re-render)
animationDurationnumber400Delay before unmounting (ms)
<Mount open={isOpen} animationDuration={300}>
  <div className="fade-out-on-close">Content</div>
</Mount>
<Mount open={isOpen} animationDuration={300}>
  <div className="fade-out-on-close">Content</div>
</Mount>

MountMinimal

A more advanced mount helper that reads the element's CSS transition-duration to determine when to unmount, rather than using a fixed duration.

PropTypeDefaultDescription
openbooleanfalseWhether to show children
forceMountbooleanfalseForce mount regardless of open state
skipWaitingbooleanfalseUnmount immediately without waiting for transitions
renderOncebooleanfalseKeep mounted after first render
refHTMLDialogElement | null--Element to observe for transition duration