Drawer

Description

The Drawer component is a fully customizable and accessible drawer modal component built with React and TypeScript. It provides an intuitive and smooth user experience, supporting drag interactions and seamless state management.

Usage

Drawer Title

This is a simple Drawer example.


import { Drawer, Button } from "mogora-ui";

export default function DrawerDemo() {
  return (
    <Drawer>
      <Drawer.Trigger>
        <Button variant="clicki">Open Drawer</Button>
      </Drawer.Trigger>
      <Drawer.Content>
        <div className="h-full flex flex-col items-center pt-5 md:w-md w-full">
          <h2 className="text-lg font-bold">Drawer Title</h2>
          <p className="mt-2">This is a simple Drawer example.</p>
        </div>
      </Drawer.Content>
    </Drawer>
  )
}

API Reference

Drawer

The main component that manages the state of the drawer.

PropTypeDescription
openbooleanControls whether the drawer is open or not.
onOpenChange(open: boolean) => voidCallback fired when the drawer state changes.
classNamestringAdditional classes for the drawer container.
childrenReactNodeComponents inside the drawer provider.

Drawer.Trigger

A component that toggles the drawer open or closed.

PropTypeDescription
onClick(e: React.MouseEvent) => voidFunction to handle click events.
classNamestringAdditional classes for the trigger.
childrenReactNodeElements inside the trigger.

Drawer.Content

The content container inside the drawer.

PropTypeDescription
render() => ReactNodeOptional function to render a custom header.
classNamestringAdditional classes for the content.
childrenReactNodeElements inside the drawer content.