Drawer

A panel that slides in from an edge of the screen, the right by default, for work that sits beside the page: its header at the top and its footer at the foot.

import { Button } from "@produkto/ui/Button";
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@produkto/ui/Drawer";

const Example = () => (
  <Drawer>
    <DrawerTrigger asChild>
      <Button>Button</Button>
    </DrawerTrigger>
    <DrawerContent>
      <DrawerHeader>
        <DrawerTitle>Title</DrawerTitle>
        <DrawerDescription>Description</DrawerDescription>
      </DrawerHeader>
      <DrawerFooter>
        <DrawerClose asChild>
          <Button>Button</Button>
        </DrawerClose>
      </DrawerFooter>
    </DrawerContent>
  </Drawer>
);

export default Example;

Usage

import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@produkto/ui/Drawer";
<Drawer>
  <DrawerTrigger>Button</DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Title</DrawerTitle>
      <DrawerDescription>Description</DrawerDescription>
    </DrawerHeader>
  </DrawerContent>
</Drawer>

Examples

Sizes

size caps the width of a drawer on the left or the right from 640px: sm 320px, base 384px (the default) or lg 448px, three quarters of a phone's screen at each; on the top or the bottom, where it grows with its content at base, sm holds it to half the screen and lg opens it at least that tall.

import { Button } from "@produkto/ui/Button";
import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
  type DrawerSize,
} from "@produkto/ui/Drawer";

const sizes: { size: DrawerSize; label: string }[] = [
  { size: "sm", label: "Small" },
  { size: "base", label: "Base" },
  { size: "lg", label: "Large" },
];

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    {sizes.map((item) => (
      <Drawer key={item.size}>
        <DrawerTrigger asChild>
          <Button>{item.label}</Button>
        </DrawerTrigger>
        <DrawerContent size={item.size}>
          <DrawerHeader>
            <DrawerTitle>Title</DrawerTitle>
            <DrawerDescription>Description</DrawerDescription>
          </DrawerHeader>
        </DrawerContent>
      </Drawer>
    ))}
  </div>
);

export default Example;

Side

side picks the edge the drawer slides in from: top, right (the default), bottom or left.

import { Button } from "@produkto/ui/Button";
import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
  type DrawerSide,
} from "@produkto/ui/Drawer";

const sides: { side: DrawerSide; label: string }[] = [
  { side: "top", label: "Top" },
  { side: "right", label: "Right" },
  { side: "bottom", label: "Bottom" },
  { side: "left", label: "Left" },
];

const Example = () => (
  <div className="flex flex-wrap items-center gap-2">
    {sides.map((item) => (
      <Drawer key={item.side}>
        <DrawerTrigger asChild>
          <Button>{item.label}</Button>
        </DrawerTrigger>
        <DrawerContent side={item.side}>
          <DrawerHeader>
            <DrawerTitle>Title</DrawerTitle>
            <DrawerDescription>Description</DrawerDescription>
          </DrawerHeader>
        </DrawerContent>
      </Drawer>
    ))}
  </div>
);

export default Example;

Layout

layout="docked" paints the drawer like a docked Sidebar, on the sidebar ground with a line on its inner edge and no shadow, where floating, the default, lifts it on the popover surface.

import { Button } from "@produkto/ui/Button";
import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@produkto/ui/Drawer";

const Example = () => (
  <Drawer>
    <DrawerTrigger asChild>
      <Button>Button</Button>
    </DrawerTrigger>
    <DrawerContent layout="docked">
      <DrawerHeader>
        <DrawerTitle>Title</DrawerTitle>
        <DrawerDescription>Description</DrawerDescription>
      </DrawerHeader>
    </DrawerContent>
  </Drawer>
);

export default Example;

Show close button

showCloseButton={false} takes the close button out of the corner, where it shows by default, leaving Escape and a click outside to close the drawer.

import { Button } from "@produkto/ui/Button";
import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@produkto/ui/Drawer";

const Example = () => (
  <Drawer>
    <DrawerTrigger asChild>
      <Button>Button</Button>
    </DrawerTrigger>
    <DrawerContent showCloseButton={false}>
      <DrawerHeader>
        <DrawerTitle>Title</DrawerTitle>
        <DrawerDescription>Description</DrawerDescription>
      </DrawerHeader>
    </DrawerContent>
  </Drawer>
);

export default Example;

Scrollable

scrollable={false} stops the drawer scrolling as one, so a bordered DrawerHeader and DrawerFooter stay in place around a ScrollArea of its own; by default everything scrolls together.

import { Button } from "@produkto/ui/Button";
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@produkto/ui/Drawer";
import { ScrollArea } from "@produkto/ui/ScrollArea";

const paragraphs: string[] = Array.from({ length: 10 }, () =>
  "Content goes here. ".repeat(6).trim(),
);

const Example = () => (
  <Drawer>
    <DrawerTrigger asChild>
      <Button>Button</Button>
    </DrawerTrigger>
    <DrawerContent aria-describedby={undefined} scrollable={false}>
      <DrawerHeader bordered>
        <DrawerTitle>Title</DrawerTitle>
      </DrawerHeader>
      <ScrollArea className="min-h-0 flex-1">
        <div className="flex flex-col gap-4 px-3">
          {paragraphs.map((paragraph, index) => (
            <p key={index}>{paragraph}</p>
          ))}
        </div>
      </ScrollArea>
      <DrawerFooter bordered>
        <DrawerClose asChild>
          <Button size="sm">Button</Button>
        </DrawerClose>
      </DrawerFooter>
    </DrawerContent>
  </Drawer>
);

export default Example;

API Reference

It takes the props of Radix Dialog.Root.

DrawerTrigger

DrawerTriggerProps · takes the props of Radix Dialog.Trigger

DrawerClose

DrawerCloseProps · takes the props of Radix Dialog.Close

DrawerContent

DrawerContentProps · also takes the props of Radix Dialog.Content
PropTypeDefault
sideDrawerSide"top" | "right" | "bottom" | "left""right"
sizeDrawerSize"sm" | "base" | "lg""base"
layoutDrawerLayout"floating" | "docked""floating"
showCloseButtonbooleantrue
scrollablebooleantrue

DrawerHeader

DrawerHeaderProps · also takes the props of <div>
PropTypeDefault
borderedbooleanfalse

DrawerFooter

DrawerFooterProps · also takes the props of <div>
PropTypeDefault
borderedbooleanfalse

DrawerTitle

DrawerTitleProps · takes the props of Radix Dialog.Title

DrawerDescription

DrawerDescriptionProps · takes the props of Radix Dialog.Description