Skip to content
Primitives

Drawer

Edge-anchored drawer (vaul) with HUD styling.

● LIVE

[ interactive — use the trigger to open ]

npx shadcn@latest add https://okibi.cndr.dev/r/drawer.json

Installation

Install the theme first, then add the component:

npx shadcn@latest add https://okibi.cndr.dev/r/drawer.json

Install the required dependencies:

npm install lucide-react vaul

Copy the source from the Code tab above into components/ui/drawer.tsx. It uses the cn helper and the okibi theme tokens — install the theme first if you haven't.

Usage

import {
  Drawer,
  DrawerContent,
  DrawerDescription,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

<Drawer>
  <DrawerTrigger>Open</DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Telemetry</DrawerTitle>
      <DrawerDescription>Live channel readout.</DrawerDescription>
    </DrawerHeader>
  </DrawerContent>
</Drawer>

Anatomy

<Drawer direction="right">
  <DrawerTrigger>Open</DrawerTrigger>
  <DrawerContent>
    <DrawerHeader>
      <DrawerTitle>Telemetry</DrawerTitle>
      <DrawerDescription>Live channel readout.</DrawerDescription>
    </DrawerHeader>
    <DrawerFooter>
      <DrawerClose>Close</DrawerClose>
    </DrawerFooter>
  </DrawerContent>
</Drawer>

Examples

Right

Set direction="right" to anchor the drawer to the right edge; the close control sits top-right.

● LIVE

[ interactive — use the trigger to open ]

Left

direction="left" anchors the drawer to the left edge.

● LIVE

[ interactive — use the trigger to open ]

Top

direction="top" drops the drawer down from the top edge.

● LIVE

[ interactive — use the trigger to open ]

API Reference

Drawer

PropTypeDefaultDescription
direction"top" | "bottom" | "left" | "right""bottom"Edge the drawer anchors to and slides from.

DrawerContent

PropTypeDefaultDescription
showCloseButtonbooleantrueRender the top-right close (X) control — the visible dismiss for edge-anchored drawers.

Accessibility

  • Built on vaul, whose Radix-wired DrawerTitle and DrawerDescription make the panel labelled and described by construction.
  • Set the anchor edge with direction (top / bottom / left / right) on the Drawer root; the content's edge, border, and slide-in follow it.
  • DrawerContent renders a close (X) control by default (showCloseButton) with an sr-only 'Close' label and a 44px pointer hit area — the visible dismiss for edge-anchored drawers that can't be swiped.
  • Native drag / swipe-to-dismiss, overlay fade, and Esc are owned by vaul; the global reduced-motion guard handles motion.

Guidelines

Do

  • Pick direction to match the content: bottom for mobile sheets, left / right for side panels.
  • Keep showCloseButton on for left / right drawers — they have no swipe handle, so the X is the only visible dismiss.
  • Always provide a DrawerTitle (and ideally a DrawerDescription) so the panel is named and described.

Don't

  • Don't hide the close button on a side drawer without supplying another labeled dismiss in the footer.
  • Don't pour long content into a top / bottom drawer without internal scrolling — they cap at max-h-[80vh] and can clip.
  • Don't reintroduce rounded corners or drop the strong border; the edge-snapped HUD panel is the look.

On this page