Display UI

Drawer

A hidden panel that slides in from the side of the screen to reveal navigation or additional actions without disrupting the main view.

Loading...

Installation

npx shadcn@latest add https://display-ui.vercel.app/r/Drawer

Usage

import { Drawer } from "@/components/display-ui/Button"
<Drawer.Main side="bottom" className="">
  <Drawer.Trigger className="px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">
    Below Drawer
  </Drawer.Trigger>
  {/* w-[50%] => if right or left for overlapping the main screen horizontally*/}
  {/* h-[50%] => if top or bottom for overlapping the main screen vertically*/}
  <Drawer.Content className="p-6 bg-white shadow-lg">
    <h2 className="text-lg font-semibold mb-4">Drawer Title</h2>
    <p className="text-sm text-gray-600 mb-6">
      This is a simple drawer for testing. You can add any content you want
      here.
    </p>
    <Drawer.Close className="px-3 py-2 bg-red-500 text-white rounded hover:bg-red-600">
      Close
    </Drawer.Close>
  </Drawer.Content>
</Drawer.Main>

API

Drawer Props

For Drawer Main

AttributeTypeDescriptionDefault
childrenReactNode | ReactNode[]Root container for the drawer. Must wrap Drawer.Trigger and Drawer.Content components.-
defaultOpenbooleanControls whether the drawer is open by default on initial render.false
side"left" | "right" | "top" | "bottom"Defines the side from which the drawer appears."right"

For Drawer Trigger

AttributeTypeDescriptionDefault
childrenReactNodeContent displayed inside the trigger button that opens the drawer.-
classNamestringAdditional CSS classes to customize the trigger button styling.-

For Drawer Content

AttributeTypeDescriptionDefault
childrenReactNode | ReactNode[]Main container for drawer content. Typically includes Header, Body, and Footer.-
classNamestringAdditional CSS classes to customize the drawer content container.-

For Drawer Header

AttributeTypeDescriptionDefault
childrenReactNodeHeader section of the drawer, typically used for titles or headings.-
classNamestringAdditional CSS classes to customize the drawer header styling.-

For Drawer Body

AttributeTypeDescriptionDefault
childrenReactNode | ReactNode[]Scrollable main content area of the drawer.-
classNamestringAdditional CSS classes to customize the drawer body styling.-

For Drawer Footer

AttributeTypeDescriptionDefault
childrenReactNode | ReactNode[]Footer section of the drawer, commonly used for actions.-
classNamestringAdditional CSS classes to customize the drawer footer styling.-

For Drawer Close

AttributeTypeDescriptionDefault
childrenReactNodeLabel displayed inside the close button. Closes the drawer when clicked."Close"
classNamestringAdditional CSS classes to customize the close button styling.-

Examples

Top Drawer

Loading...

Bottom Drawer

Loading...

left Drawer

Loading...

Right Drawer

Loading...

Credits

This component is inspired by Rehman Kalawant Design Shared On Github.

On this page