Components

Drawer

A draggable React drawer built on shadcn/ui and vaul: swipe-to-dismiss bottom sheets and side drawers with a handle bar and dimmed backdrop, plus a responsive dialog that becomes a drawer on phones and an Apple Maps-style snap-points sheet.

  • Drop-in shadcn API
  • vaul
  • Drag to dismiss
  • Snap points
  • Responsive dialog

Installation

$ npx shadcn@latest add https://duskui.com/r/drawer.json

Adds components/ui/drawer.tsx with the shadcn exports. vaul injects its slide keyframes as unlayered CSS; the reduced-motion fade override uses !important utilities for that reason.

Usage

goal-drawer.tsx
import { Button } from "@/components/ui/button"
import {
  Drawer,
  DrawerClose,
  DrawerContent,
  DrawerDescription,
  DrawerFooter,
  DrawerHeader,
  DrawerTitle,
  DrawerTrigger,
} from "@/components/ui/drawer"

export function GoalDrawer() {
  return (
    <Drawer>
      <DrawerTrigger asChild>
        <Button variant="outline">Open</Button>
      </DrawerTrigger>
      <DrawerContent>
        <DrawerHeader>
          <DrawerTitle>Move goal</DrawerTitle>
          <DrawerDescription>Set your daily activity goal.</DrawerDescription>
        </DrawerHeader>
        <DrawerFooter>
          <DrawerClose asChild>
            <Button>Done</Button>
          </DrawerClose>
        </DrawerFooter>
      </DrawerContent>
    </Drawer>
  )
}

Examples

Default

A bottom drawer with the handle bar. Drag it down past the threshold (or flick it) to dismiss, or use Escape, the backdrop or a DrawerClose button.

Directions

Set direction on Drawer to top, right, bottom or left. Side drawers are three quarters wide on phones and cap at max-w-sm.

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Responsive Dialog

A centered Dialog on desktop and a drag-to-dismiss Drawer on phones, from one set of parts. A useSyncExternalStore media-query hook keeps server and client markup identical, and the open state lives in the block so resizing swaps the surface without closing it. Header, body and footer rise in with a short stagger on both surfaces.

Resize below 768px to get the drawer.

$ npx shadcn@latest add https://duskui.com/r/responsive-dialog.json
PropTypeDefaultDescription
open / defaultOpen / onOpenChangebooleanfalseOn ResponsiveDialog: controlled or uncontrolled state, shared by both surfaces.
desktopQuerystring"(min-width: 768px)"Media query that switches to the Dialog.
showCloseButtonbooleantrueOn ResponsiveDialogContent: the X button on desktop.
Trigger / CloseasChild button props—Open and close from either surface.
Header / Title / Description / Body / Footerparts—Mirror the Dialog API; Body pads itself on phones.
useMediaQuery(query, serverValue?)hook—The hydration-safe matchMedia hook, exported for reuse.

Snap Drawer

A bottom sheet with snap points, like Apple Maps: drag between resting heights, flick to skip one, or tap the indicator dots — a pill glides between them and the handle widens as the sheet grows. The backdrop fades in from the second point, and content only scrolls at full height so dragging never fights scrolling. nonModal keeps the page usable behind it.

$ npx shadcn@latest add https://duskui.com/r/snap-drawer.json
PropTypeDefaultDescription
triggerReactElement—Element that opens the drawer. Omit when controlling `open`.
open / defaultOpen / onOpenChangebooleanfalseControlled or uncontrolled state.
snapPoints(number | string)[][0.3, 0.6, 1]Resting heights, smallest first: screen fractions or "160px".
snap / onSnapChangenumber | string | null—Controlled resting point.
snapLabelsstring[]—Accessible names for the indicator buttons.
title / descriptionReactNode—Dialog title and description.
peekReactNode—Row shown at every height, under the title.
nonModalbooleanfalseNo backdrop; the page stays interactive.

API Reference

Same parts as shadcn/ui: Drawer, DrawerTrigger, DrawerPortal, DrawerOverlay, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription and DrawerClose. Drawer takes every vaul Root prop.

PropTypeDefaultDescription
direction"top" | "right" | "bottom" | "left""bottom"On Drawer: the edge it slides from.
snapPoints / activeSnapPoint / setActiveSnapPoint(number | string)[]—On Drawer: resting heights and the controlled current one.
dismissiblebooleantrueOn Drawer: allow drag, Escape and backdrop to close it.
handleOnlybooleanfalseOn Drawer: only vaul's Drawer.Handle starts a drag.
shouldScaleBackgroundbooleanfalseOn Drawer: scale a [data-vaul-drawer-wrapper] element behind it.
showHandlebooleantrueOn DrawerContent: the handle bar on bottom drawers.

Accessibility

  • Built on vaul, which uses Radix Dialog: focus is trapped inside, Escape closes, and the title and description are wired to aria-labelledby / aria-describedby.
  • Dragging is a pointer enhancement — every drawer can also be closed with Escape, the backdrop or a close button.
  • The snap drawer's indicator dots are labelled buttons with aria-pressed, so keyboard users can change its height.
  • Under prefers-reduced-motion drawers fade in and out instead of sliding, and snap changes jump.