Searching Open Sourcery

Type to search Open Sourcery.

Overlays & Panels

Bottom Sheet

The lean bottom-only build: pointer dragging, velocity dismissal, scroll-aware gesture policy, safe-area spacing.

v2.0.2@magic-spells/bottom-sheet

$ npm i @magic-spells/bottom-sheet

GitHubnpm

Live demo

Filters

Scroll this list. At the top of it, keep pulling down and the same gesture starts to drag the sheet.

Release above the lower snap point and it settles there; flick and it steps one snap in that direction.

Drag below the shortest snap and the gesture becomes a dismiss.

Filter group 1

Filter group 2

Filter group 3

Filter group 4

Filter group 5

Filter group 6

Filter group 7

Filter group 8

Filter group 9

Filter group 10

Filter group 11

Filter group 12

Scrolling hands off to dragging.

About

Accessible bottom-sheet custom elements built on @magic-spells/dialog-panel. The sheet keeps modal behavior in the native `` layer and adds Pointer Events dragging, velocity dismissal, scroll-aware gesture policy, and safe-area spacing.

Features

  • Pointer Events gestures work with mouse, touch, and pen
  • Fast downward flicks dismiss without a long drag
  • Optional snap points through snap-points, driven by height so the footer stays pinned at every snap
  • Scrollable content hands the gesture to the panel mid-drag, the moment the list runs out
  • Optional detached, fully rounded presentation through inset
  • Upward drags use a restrained rubber-band transform

Usage

<button id="open-sheet">Open sheet</button>

<dialog-panel id="sheet-panel">
	<dialog aria-labelledby="sheet-title">
		<bottom-sheet>
			<bottom-sheet-header>
				<h2 id="sheet-title">A useful title</h2>
				<button data-action-hide-dialog aria-label="Close">&times;</button>
			</bottom-sheet-header>

			<bottom-sheet-content>
				<p>Scrollable sheet content goes here.</p>
			</bottom-sheet-content>

			<bottom-sheet-footer>
				<button>Primary action</button>
			</bottom-sheet-footer>
		</bottom-sheet>
	</dialog>
</dialog-panel>

<script type="module">
	const trigger = document.querySelector('#open-sheet');
	const sheet = document.querySelector('bottom-sheet');

	trigger.addEventListener('click', () => sheet.show(trigger));
</script>

About, features, usage and options are taken from the package README.