Drawer · side panel
Panels that slide in from any edge and out again — draggable to close, focus kept inside, stacking, guarded against losing unsaved changes, and a non-modal mode.
Edges
Sizes · stacking · guards · non-modal
Esc or the backdrop closes the top drawer · drag a header or the handle toward the edge · Tab stays inside while it's open.
Usage
import { signal } from "./index.js";import { Drawer } from "./components/drawer.js"; const open = signal(false); // side: "right" (default) · "left" · "bottom" · "top"// size: "sm" · "md" · "lg" · "xl" · "full" — or any CSS lengthDrawer({ open, title: "Filters", description: "Narrow down 1,284 products", children: html`…`, footer: html`${Button({ label: "Show results", onClick: () => open.set(false) })}`,}) // a bottom sheet with a drag handle — drag it down to closeDrawer({ open: share, side: "bottom", title: "Share", children: shareButtons }) // keep it open while there are unsaved changesDrawer({ open: edit, title: "Edit note", beforeClose: () => !dirty() || confirmDiscard() }) // no backdrop, no scroll lock: the page stays usableDrawer({ open: inspector, modal: false, size: "sm", title: "Inspector" }) // Esc / backdrop / ✕ / dragging close it; focus stays inside and returns after.// A drawer opened from a drawer stacks — the one below steps back.