StealThis .dev

Sheet / Drawer

Slide-in sheet panels from all four edges — bottom sheet (mobile-first), right sidebar drawer, left nav drawer, and top notification drawer.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

Sheet / Drawer

A set of slide-in sheet panels that animate in from any of the four screen edges. Built with pure CSS transforms and vanilla JS — no dependencies.

Variants

  • Bottom sheet — mobile-first, drag-to-dismiss with touch and mouse
  • Right drawer — sidebar pattern, slides in from the right
  • Left drawer — navigation drawer, slides in from the left
  • Top drawer — notification or search bar, slides down from top

How it works

  1. Each drawer is position: fixed and starts off-screen via transform: translateY/translateX(100% / -100%)
  2. Adding the .open class transitions it to transform: none
  3. A translucent backdrop sits behind the active drawer; clicking it closes the drawer
  4. The bottom sheet supports drag-to-dismiss: tracking touchstart/mousemove delta and dismissing if dragged past 40% of its height
  5. Pressing Escape closes the active drawer

Accessibility

  • Drawer panels use role="dialog" and aria-modal="true"
  • Focus is trapped inside the open drawer
  • Close button always present and keyboard-reachable