logonpix

Drawer

Example
Props

Open

Backdrop

Placement

Installation
npx npix@latest add Drawer
Usage
<>
  <Button onClick={()=>r(!e)}>
    Try me
  </Button>
  <Drawer
    backdrop
    handleClose={()=>r(!1)}
    placement="right"
  >
    <header>
      <DrawerTitle>
        John Smith
      </DrawerTitle>
      <DrawerDescription>
        jhon.smith@xyz.com
      </DrawerDescription>
    </header>
    <main className="my-4 border-t border-b border-border px-2 py-4 grow block">
      <div className="flex space-x-8 items-center hover:bg-accent-hover rounded-md p-2 hover:cursor-pointer">
        <EnvelopeIcon className="w-5 h-5" />
        <div className="col-span-5">
          Inbox
        </div>
      </div>
      <div className="flex space-x-8 items-center hover:bg-accent-hover rounded-md p-2 hover:cursor-pointer">
        <HeartIcon className="w-5 h-5" />
        <div className="col-span-5">
          Favorites
        </div>
      </div>
      <div className="flex space-x-8 items-center hover:bg-accent-hover rounded-md p-2 hover:cursor-pointer">
        <ExclamationCircleIcon className="w-5 h-5" />
        <div className="col-span-5">
          Spam
        </div>
      </div>
      <div className="flex space-x-8 items-center hover:bg-accent-hover rounded-md p-2 hover:cursor-pointer">
        <TrashIcon className="w-5 h-5" />
        <div className="col-span-5">
          Trash
        </div>
      </div>
      <div className="flex space-x-8 items-center hover:bg-accent-hover rounded-md p-2 hover:cursor-pointer">
        <Cog6ToothIcon className="w-5 h-5" />
        <div className="col-span-5">
          Settings
        </div>
      </div>
    </main>
    <footer>
      <Button type="danger">
        Report an issue
      </Button>
    </footer>
  </Drawer>
</>
API

open

boolean

Whether the drawer is open or not


handleClose

Function

What to do when the user clicks the 'X' button or presses Esc to close the drawer


backdrop

boolean

If true, darken the area outside of the drawer to create a backdrop


placement

"left" | "top" | "right" | "bottom"

Where to place the drawer


FieldDescriptionType
openWhether the drawer is open or notboolean
handleCloseWhat to do when the user clicks the 'X' button or presses Esc to close the drawerFunction
backdropIf true, darken the area outside of the drawer to create a backdropboolean
placementWhere to place the drawer"left" | "top" | "right" | "bottom"