StorybookGitHub

Drawer

A drawer component for menus and content that slides from an edge of the screen.

Installation

npx shadcn@latest add https://reactdocs.canceydejean.dev/r/drawer.json

Usage

Use a drawer for mobile-friendly sheets of content that slide in from an edge. Built on Base UI Drawer.

import { Button } from "@/components/button/button";
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/drawer/drawer";

export function Example() {
  return (
    <Drawer>
      <DrawerTrigger render={<Button variant="outline" />}>
        Open Drawer
      </DrawerTrigger>
      <DrawerContent>
        <DrawerHeader>
          <DrawerTitle>Move Goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <DrawerFooter>
          <Button>Submit</Button>
          <DrawerClose render={<Button variant="outline" />}>
            Cancel
          </DrawerClose>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  );
}

Set swipeDirection to "down", "up", "left", or "right". Pass showSwipeHandle for a visible drag indicator, and snapPoints for multi-height drawers.