Skip to main content

Drawer

A swipeable gesture drawer with 1:1 pointer tracking, velocity-based fling dismissal, rubber-band resistance, and four-direction docking.

goal=350 kcal·direction="bottom"

Customize

Motion blur (px)6
Speed1

Installation

npx shadcn@latest add @kinetic/drawer

Usage

import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/kinetic/ui/drawer";

export function ShareDrawer() {
  return (
    <Drawer>
      <DrawerTrigger>Share</DrawerTrigger>
      <DrawerContent>
        <DrawerHeader>
          <DrawerTitle>Share link</DrawerTitle>
          <DrawerDescription>Anyone with the link can view.</DrawerDescription>
        </DrawerHeader>
        <DrawerFooter>
          <DrawerClose>Done</DrawerClose>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  );
}

Direction

Set direction on Drawer to bottom (default), top, left, or right. The drag and dismiss gesture follows the docked edge.

<Drawer direction="right">...</Drawer>

Gestures

Drag the content (or the handle shown for bottom and top) toward its edge to dismiss it. Dragging does not start on buttons, links, form fields, or elements marked data-drawer-no-drag. The panel follows the pointer 1:1, resists with a rubber band when pulled the other way, and closes on release when the drag distance or fling velocity is large enough.

Non-dismissible

Set dismissible={false} to disable swipe, Escape, and outside dismissal so the drawer closes only through an explicit control such as DrawerClose.

<Drawer dismissible={false}>...</Drawer>

Controlled state

Pass open and onOpenChange to control the drawer, or defaultOpen for an uncontrolled initial state.

<Drawer open={open} onOpenChange={setOpen}>
  ...
</Drawer>

Nested drawers

Use DrawerNested inside a drawer's content. The parent recedes while the child is open.

import { DrawerNested } from "@/components/kinetic/ui/drawer";

<DrawerNested>
  <DrawerTrigger>More options</DrawerTrigger>
  <DrawerContent>...</DrawerContent>
</DrawerNested>

Portal and overlay

DrawerContent mounts inside a portal with a backdrop automatically. When composing explicitly, wrap DrawerOverlay and DrawerContent inside DrawerPortal (optionally passing container). DrawerOverlay stays synchronized 1:1 with pointer drag opacity, and DrawerTrigger and DrawerClose support asChild.

import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerOverlay,
  DrawerPortal,
  DrawerTrigger,
} from "@/components/kinetic/ui/drawer";
import { Button } from "@/components/kinetic/ui/button";

<Drawer>
  <DrawerTrigger asChild>
    <Button variant="outline">Open drawer</Button>
  </DrawerTrigger>
  <DrawerPortal>
    <DrawerOverlay className="bg-black/60" />
    <DrawerContent>
      <DrawerClose asChild>
        <Button variant="outline">Close</Button>
      </DrawerClose>
    </DrawerContent>
  </DrawerPortal>
</Drawer>

Speed and blur

speed scales the animation and blurPx sets the blur applied to the panel while it enters and exits. DrawerContent also accepts blurPx and overlayClassName.

<Drawer speed={1.25} blurPx={6}>...</Drawer>

Motion preferences

With reduced motion enabled, the drawer skips the slide animation and the nested recede transform. Animation timing follows the current Kinetic tempo. Focus is trapped while open and Escape closes the drawer when it is dismissible, and focus returns to the trigger after it closes.

API Reference

Drawer

Zero-dependency gesture drawer root supporting four directions, velocity fling dismiss, and rubber-band overdrag.

PropTypeDefaultDescription
direction"bottom" | "top" | "left" | "right""bottom"Edge from which the drawer enters and accepts swipe dismissal.
dismissiblebooleantrueAllows closing via drag gesture, backdrop click, or Escape key.
speed / blurPxnumber1 / 6Enter/exit/snap-back animation speed multiplier and motion blur radius (px).
open / defaultOpen / onOpenChangeboolean / (open: boolean) => void-Controlled or uncontrolled visibility state.

DrawerPortal / DrawerOverlay / DrawerTrigger / DrawerClose

Explicit portal container, drag-synced backdrop overlay, and asChild trigger/close wrappers.

PropTypeDefaultDescription
container (DrawerPortal)Element | nulldocument.bodyOptional DOM target for portaled drawer overlay and panel.
asChild (DrawerTrigger / DrawerClose)booleanfalseMerges open or close handlers onto a child button element.

DrawerContent

Portaled drag-enabled surface with automatic drag handle on bottom/top orientations and focus trap.

PropTypeDefaultDescription
overlayClassName / blurPxstring / number-Optional className for the implicit backdrop overlay and per-content blurPx override.

Notes

DrawerTitle is required inside DrawerContent for accessibility (use className='sr-only' when visually hidden). The drag handle renders automatically only when direction='bottom'.