Skip to main content
Version: 1.0.2

Drawer

Overview

The Drawer component provides a sliding panel that can be positioned from any side of the screen. It supports multiple animation types, customizable sizes, and includes features like overlay, keyboard navigation, and accessibility support.

Preview

Click the button above to open the drawer

Installation

npx @mindfiredigital/ignix-ui add drawer

Usage

import { Drawer } from './components/drawer';

function MyComponent() {
const [isOpen, setIsOpen] = useState(false);

return (
<>
<Button onClick={() => setIsOpen(true)}>Open Drawer</Button>

<Drawer
isOpen={isOpen}
onClose={() => setIsOpen(false)}
position="right"
animationType="slide"
size="350px"
showOverlay={true}
title="My Drawer"
>
<div className="p-4">
<h3>Drawer Content</h3>
<p>This is the content of the drawer.</p>
</div>
</Drawer>
</>
);
}

Props

PropTypeDefaultDescription
isOpenboolean-Controls whether the drawer is open or closed
onClose() => void-Callback function called when the drawer should close
childrenReact.ReactNode-Content to be displayed inside the drawer
position'left' | 'right' | 'top' | 'bottom''right'Position of the drawer relative to the screen
sizestring | number'350px'Size of the drawer (width for left/right, height for top/bottom)
showOverlaybooleantrueWhether to show a backdrop overlay
closeOnOverlayClickbooleantrueWhether clicking the overlay closes the drawer
titleReact.ReactNode-Optional title displayed in the drawer header
footerReact.ReactNode-Optional footer content
classNamestring-Additional CSS classes for the drawer container
animationType'slide' | 'reveal' | 'fade' | 'hinge' | 'zoom' | 'flip''slide'Type of animation to use when opening/closing
zIndexnumber1000Z-index for the drawer and overlay

Examples

Form Drawer

<Drawer
isOpen={isOpen}
onClose={() => setIsOpen(false)}
position="right"
size="400px"
title="Edit Profile"
footer={
<div className="flex justify-end gap-2">
<Button variant="outline" onClick={() => setIsOpen(false)}>Cancel</Button>
<Button variant="default">Save Changes</Button>
</div>
}
>
<form className="p-4 space-y-4">
<input placeholder="Name" className="w-full p-2 border rounded" />
<input placeholder="Email" className="w-full p-2 border rounded" />
</form>
</Drawer>