Motion Drawer

A motion drawer component for React with smooth Framer Motion animations. Functions as a collapsible navigation drawer on mobile and a persistent sidebar on desktop.

Componendt not found

Installation

npx uilayouts@latest add motion-drawer

Props

PropTypeDefaultDescription
overlayColorstring'rgba(0, 0, 0, 0.3)'Color of the background overlay.
widthnumber300Width of the side menu.
direction'left' | 'right''left'The direction from which the menu opens.
backgroundColorstring'#ffffff'Background color of the side menu.
childrenReact.ReactNodeThe content to display inside the side menu.
isOpenbooleanControls the open/closed state of the menu.
onToggle(isOpen: boolean) => voidCallback when the menu is opened or closed.
showToggleButtonbooleantrueWhether to show the toggle button.
toggleButtonText{ open: string; close: string }Custom text for the toggle button.
classNamestring''Custom className for the container.
contentClassNamestring''Custom className for the content area.
overlayClassNamestring''Custom className for the overlay.
animationConfig{ type?: 'spring' | 'tween'; damping?: number; stiffness?: number; duration?: number }{ type: 'spring', damping: 25, stiffness: 120 }Configuration for the animation.
enableDragbooleantrueWhether to allow drag-to-close.
dragThresholdnumber0.3Threshold for drag-to-close.
buttonOpeningVariants'push' | 'merge' | 'stay''merge'Controls how the toggle button animates when the menu opens.

Examples

Right Drawer