Skip to Content

API Reference

What components are available in Motion Drawer and how to use them.

Anatomy

Import all parts and piece them together.

import { Drawer, DrawerHeader, DrawerBody, DrawerActions } from "motion-drawer";
 
export function MyDrawer() {
  return (
    <Drawer>
      <DrawerHeader />
      <DrawerBody />
      <DrawerActions />
    </Drawer>
  );
}

Components API

Drawer

PropTypeDefaultDescription
asElementTypedivThe element or component the Drawer should render as.
snapPointsstring[]["auto"]Array of points the drawer can snap to. Supports all CSS valid sizes
defaultSnapPointstring-Initial snap point when drawer opens.
snapPointstring-Controlled snap point state.
onSnapPointChange(snapPoint: string) => void-Handler called when snap point changes.
openboolean-Controls drawer open/close state.
onOpenChange(open: boolean) => void-Handler called when open state changes.
defaultOpenboolean-Initial open state.
borderRadiusnumber | null16Border radius in pixels.
offsetnumber0Amount to nudge drawer from origin.
paddingnumber0Space between drawer and window edge.
closeFromFirstSnapPointbooleanfalseClose the drawer when dragging down from the first snap point.

DrawerHeader

PropTypeDefaultDescription
asElementTypedivThe element or component the DrawerHeader should render as.

DrawerBody

PropTypeDefaultDescription
asElementTypedivThe element or component the DrawerBody should render as.

DrawerActions

PropTypeDefaultDescription
asElementTypedivThe element or component the DrawerActions should render as.
Last updated on