Volt UI
Components

Drawer

A side panel that slides in from the edge of the screen, used for navigation, detail views, or supplementary content

Basic Usage

A Drawer is a side panel that slides in from the edge of the screen to display supplementary content without leaving the current page.

import { Drawer, DrawerTrigger, DrawerContent, DrawerPortal, DrawerOverlay, DrawerFooter, DrawerClose, DrawerHeader, DrawerTitle, DrawerDescription, Button } from "@epilot/volt-ui"

<Drawer>
  <DrawerTrigger asChild>
    <Button variant="primary">Open Drawer</Button>
  </DrawerTrigger>
  <DrawerPortal container={document.getElementById("root")}>
    <DrawerOverlay />
    <DrawerContent className="w-96">
      <DrawerHeader>
        <DrawerTitle>Details</DrawerTitle>
        <DrawerDescription>
          View and edit the details below.
        </DrawerDescription>
      </DrawerHeader>
      <div className="flex flex-col gap-4 flex-1 overflow-auto">
        <p>Drawer content goes here.</p>
      </div>
      <DrawerFooter>
        <DrawerClose asChild>
          <Button variant="secondary">Close</Button>
        </DrawerClose>
        <Button>Save</Button>
      </DrawerFooter>
    </DrawerContent>
  </DrawerPortal>
</Drawer>

Side Variants

The side prop controls which edge the drawer slides in from. The default is "right".

<Drawer>
  <DrawerTrigger asChild>
    <Button>Open Left</Button>
  </DrawerTrigger>
  <DrawerPortal container={document.getElementById("root")}>
    <DrawerOverlay />
    <DrawerContent side="left" className="w-80">
      <DrawerHeader>
        <DrawerTitle>Left Drawer</DrawerTitle>
      </DrawerHeader>
      <p>This drawer slides in from the left.</p>
    </DrawerContent>
  </DrawerPortal>
</Drawer>

API Reference

Drawer

The root component that wraps the drawer trigger and content.

PropTypeDefaultDescription
openboolean-Controlled open state of the drawer.
defaultOpenbooleanfalseUncontrolled default open state.
onOpenChange(open: boolean) => void-Callback fired when the open state changes.
modalbooleantrueWhen true, focus is trapped within the drawer and outside interaction is disabled.

DrawerTrigger

The element that triggers the drawer. Use asChild to merge props with a child element.

PropTypeDefaultDescription
asChildbooleanfalseWhen true, merges props with the child element instead of rendering a button.

DrawerPortal

The portal component that renders the drawer content outside the DOM hierarchy.

PropTypeDefaultDescription
containerElement / DocumentFragment-The container to render the portal in. Recommended to use your MFE root element (e.g., document.getElementById("epilot360-entity")) instead of document.body to avoid conflicts.
forceMountbooleanfalseWhen true, the drawer content is always mounted.

DrawerOverlay

The backdrop overlay that appears behind the drawer content.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the overlay.

DrawerHeader

A container component for the drawer title and description.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the header container.

DrawerTitle

The title element for the drawer. Required for accessibility.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the title.

DrawerDescription

The description element for the drawer. Provides additional context about the drawer.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the description.

DrawerClose

A button element that closes the drawer when clicked. Use asChild to merge props with a child element.

PropTypeDefaultDescription
asChildbooleanfalseWhen true, merges props with the child element instead of rendering a button.
classNamestring-Additional CSS classes to apply to the close button.

Body

DrawerContent

The main content container for the drawer.

PropTypeDefaultDescription
side"left" | "right" | "top" | "bottom""right"The side from which the drawer slides in.
showCloseButtonbooleantrueWhen true, displays a close button in the top-right corner.
classNamestring-Additional CSS classes to apply to the drawer content. Use to set width/height (e.g., className="w-96").

DrawerFooter

A container component for drawer action buttons.

PropTypeDefaultDescription
classNamestring-Additional CSS classes to apply to the footer container.