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

The panel follows a swipe through translate-y-[var(--bit-bh-drawer-swipe-movement-y,0px)] and the backdrop fades with --bit-bh-drawer-swipe-progress; data-[swiping]:transition-none keeps the panel under the finger. It slides in with starting:translate-y-full and out with data-[state=closed]:translate-y-full - a transition, so a swiped sheet leaves from where it was let go.

Side panel

Side="BitBhDrawerSide.Left": a swipe to the left moves it along --bit-bh-drawer-swipe-movement-x. SwipeThreshold="0.4" asks for a longer drag before letting go closes it; a quick flick still does.

Snap points

SnapPoints on a sheet as tall as the screen: it opens at a 160px peek, a drag settles it on the nearest snap point, a flick moves it on, and @bind-ActiveSnapPoint follows. The panel adds the runtime's translate-y-[calc(var(--bit-bh-drawer-snap-point-offset-y,0px)_+_var(--bit-bh-drawer-swipe-movement-y,0px))], the backdrop fades with opacity-[var(--bit-bh-drawer-fade,1)], and the handle - a slider once there are snap points (arrow keys, Home / End, Enter) - gets a padded hit area and focus-visible:outline-2. data-[snap-point=1]: styles the fully open sheet: its corners square off.

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