Skip to content

Drawer

A modal dialog that slides in from an edge of the screen - a bottom sheet, a side panel - and can be swiped away.

Styled with CSS Tailwind

Bottom sheet

A drawer is a dialog: role="dialog" named by BitBhDrawerTitle and described by BitBhDrawerDescription, focus trapped inside and returned to the trigger, the page behind it inert with its scroll locked, Escape and the backdrop close it. Drag the sheet down - anywhere, or by its BitBhDrawerHandle - and it follows the pointer through --bit-bh-drawer-swipe-movement-y (the backdrop fades with --bit-bh-drawer-swipe-progress); let go past SwipeThreshold (a quarter of its height) or flick it, and it closes, otherwise it settles back. A drag in the list while it is scrolled away from its top scrolls the list instead.

Sides

Side attaches the drawer to any edge; Start and End follow the reading direction (Start is the right edge in right-to-left). Every part gets data-side, and a swipe towards that edge moves the panel along --bit-bh-drawer-swipe-movement-x. Bound with @bind-Open, the drawer needs no trigger of its own: focus returns to the button that opened it.

Nested drawers

A drawer opened from another drawer's panel gets data-nested; the one behind it gets data-nested-drawer-open and --bit-bh-nested-drawers (how many are open in front of it), here used to scale it back. Closing the outer drawer closes the inner one too. OnDismissRequest sees every Escape, outside press and swipe (BitBhDismissReason.Swipe) and can cancel it.

Last dismissed by: nothing yet

Snap points

SnapPoints let the drawer rest part open - here a 160px peek, half the screen and all of it (Vaul-style fractions of the viewport, or pixels). Drag it and it settles on the nearest one; flick it and it moves on to the next; drag it below the smallest and it closes. The runtime rests the panel through --bit-bh-drawer-snap-point-offset-y (-x for a side panel), added to the swipe movement, and every part gets data-snap-point, which @bind-ActiveSnapPoint follows. Without a pointer, the BitBhDrawerHandle is a slider - arrow keys, Home / End, Enter to cycle - and Tab into the part of the panel a snap point hides opens it far enough to show it.

Snap point: none
An unhandled error has occurred. Reload 🗙