Drawer
Drawer exposes controlled opening, side placement and a labelled panel.
Practical React example
Open a side panel for filters or record details without replacing the main page.
Before you copy and paste
Keep the example in the React rendering environment required by the imported component. Copy components/motion/drawer.tsx and its returned support files from the Code tab; preserve the project-relative paths.
Listed package dependencies: clsx, motion, react, tailwind-merge.
Use the Code tab for the component files and installation instructions, then adapt the imports in this example to your project.
Open a side panel for filters or record details without replacing the main page
// Usage adapted from beUI's pinned MIT source.
// Copyright (c) 2026 Saurabh Chauhan. See ./LICENSES.md.
"use client";
import { useState } from "react";
import { Drawer } from "@/components/motion/drawer";
export function DrawerPreview() {
const [open, setOpen] = useState(false);
const [side, setSide] = useState<"left" | "right">("right");
const openWith = (s: "left" | "right") => {
setSide(s);
setOpen(true);
};
return (
<div className="flex items-center gap-3">
<button
type="button"
onClick={() => openWith("left")}
className="inline-flex h-10 items-center rounded-full border border-border bg-card px-5 text-sm font-medium text-foreground transition-colors hover:bg-card/70"
>
Open left
</button>
<button
type="button"
onClick={() => openWith("right")}
className="inline-flex h-10 items-center rounded-full bg-primary px-5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
>
Open right
</button>
<Drawer
open={open}
onOpenChange={setOpen}
side={side}
ariaLabel="Demo drawer"
className="gap-4 p-6"
>
<h2 className="text-sm font-semibold text-foreground">Drawer</h2>
<p className="text-sm text-muted-foreground">
Slides in from the {side}. Press Esc or click outside to close.
</p>
</Drawer>
</div>
);
}
Usage example adapted from beUI's pinned MIT source. Retain the source licence notices when copying.
Keep open in parent state and give the panel an ariaLabel. Distinguish closing the drawer from applying or clearing its filters.
Customization
- DrawerProps.open
- Required; boolean.
- DrawerProps.onOpenChange
- Required; (open: boolean) => void.
- DrawerProps.side
- Optional; "left" | "right".
- DrawerProps.children
- Required; ReactNode.
- DrawerProps.className
- Optional; string. Class for the panel surface.
- DrawerProps.backdropClassName
- Optional; string. Class for the backdrop.
- DrawerProps.ariaLabel
- Optional; string.
- DrawerProps.dismissable
- Optional; boolean. Close when the backdrop is clicked. Default true.
- PresenceGateRenderProps.isPresent
- Required; boolean. False from the render that starts the exit animation onward. An overlay kept in the tree by `AnimatePresence` is still the topmost thing on the page, so anything it decides from `open` alone stays true for the whole exit — this is the boolean that already knows the overlay is leaving.
- PresenceGateRenderProps.gate
- Required; { inert: boolean; style: { pointerEvents: "auto" | "none" }; }. Spread onto every layer that takes pointer events while the overlay is open. Interaction releases in the same commit that starts the exit while the visual exit keeps playing: pointer events stop landing, and `inert` drops the subtree from focus order, from tab order and from the accessibility tree — an exiting dialog is not a dialog you can still type into. A layer that never takes pointer events (a wrapper that only centres the panel) takes `inert={!isPresent}` alone, so its own `pointer-events-none` is not overwritten.
- PresenceGateProps.children
- Required; (props: PresenceGateRenderProps) => ReactNode.
Integration notes
- Unsaved changes need an explicit policy when the backdrop dismisses the panel.
- Test focus return, background scrolling and content overflow on mobile.
Component source: beUI documentation . These examples describe the version imported into Rendyn. Upstream APIs may have changed; retain the source licence notices when adapting the code.
Give your agent taste.
The best way to use Rendyn is through MCP. Let your agent find the right component, compare previews and bring the source into your project.
All components are free. Sign up only to connect MCP.