Drawer Slide
Slide-out drawer panel with drag-to-dismiss, spring physics, and backdrop blur.
npx uniqueui add drawer-slide
Preview
Usage
"use client";
import { useState } from "react";
import { DrawerSlide } from "@/components/ui/drawer-slide";
export default function Example() {
const [drawerOpen, setDrawerOpen] = useState(false);
return (
<>
<div className="flex items-center justify-center p-20">
<button
onClick={() => setDrawerOpen(true)}
className="px-6 py-3 rounded-lg bg-purple-600 hover:bg-purple-500 text-white transition-colors font-medium"
>
Open Drawer
</button>
</div>
<DrawerSlide isOpen={drawerOpen} onClose={() => setDrawerOpen(false)}>
<h3 className="text-xl font-bold mb-4 text-white">Drawer Content</h3>
<p className="text-neutral-400 mb-4">
This drawer slides in from the right with spring physics. You can drag it to dismiss.
</p>
<button
onClick={() => setDrawerOpen(false)}
className="px-4 py-2 rounded-lg bg-neutral-800 hover:bg-neutral-700 text-white transition-colors text-sm"
>
Close Drawer
</button>
</DrawerSlide>
</>
);
}Props
| Prop | Type | Description |
|---|---|---|
isOpen | boolean | React state abstraction determining visible rendering. |
onClose | () => void | Method triggered when dismiss actions evaluation (drag, backdrop, external limit). |
children | React.ReactNode | Content rendered inside the active sliding sheet. |
position | DrawerPosition | Anchoring enumeration bounding left, right, top, or bottom screen edges. |
className | string | Specific styling modifiers passing onto the physical sliding panel. |
overlayClassName | string | Specific styling modifiers passing onto the dimming backdrop. |
width | string | CSS explicit translation sizing left/right sliding panels. |
height | string | CSS explicit translation sizing top/bottom sliding panels. |
dragToClose | boolean | Map touch swiping events onto gesture recognizers supporting drag dismiss. |