All effects
Parameter playground

Drag a slider: the demo replays itself so the difference is visible, and the matching number inside the prompt is rewritten. Copy it and you take a prompt tuned to your taste.

Half-open anchor 38% The drawer glides to the half anchor and holds: 25 is conservative, 60 nearly full, 38 fits comment panels
Gestures

Damped Bottom Sheet

A bottom drawer that tracks your finger with rubber-band damping and snaps to anchors based on flick velocity.

AI Prompt
Implement a bottom sheet with rubber-band damping: it tracks the finger 1:1 while dragging, with increasing resistance past the top boundary; on release it automatically snaps to the nearest anchor (collapsed, half anchor at 38%, full) based on gesture velocity and position, with a subtle spring bounce. Vanilla JS.

How it works

The sheet is a fixed-position panel moved only with transform: translateY, which keeps dragging on the GPU compositor even on high refresh screens. During a drag, a pointermove listener applies the delta 1:1; past the top boundary a rubber-band function takes over - each extra pixel moves the sheet less, the classic resistance curve mobile OSes use. Release logic reads the flick velocity, sampled from the last two pointermove events as delta over timestamp, and combines it with the resting position to pick an anchor: a fast upward flick always opens fully, while a slow drift settles on the nearest of the collapsed, half and full stops.

Snap-back runs on a CSS transition with a spring-like curve for a subtle bounce, and a new pointerdown during the animation cancels it immediately so the sheet never fights your hand. The gesture code guards setPointerCapture with try/catch, because synthetic or automated pointer events can throw a NotFoundError when capture is requested - a real-world issue in embedded webviews where such events are common.

How to use this prompt

Paste the prompt with your sheet content and state the anchor heights you need - collapsed peek, half screen and full screen are the standard triple. If you use it for filters or a player queue, ask the AI to emit a callback at each anchor so you can update page state, like pausing background scroll when the sheet reaches full.

Tips for better results

Add a drag handle visual - users reach for it even though the whole surface drags. Set the rubber-band limit to roughly a third of the boundary distance so resistance is felt but never blocks. On desktop, let the ESC key and a backdrop click close from any anchor, and disable body scroll only while the sheet is fully open, otherwise the page jumps when the scrollbar disappears.

Keep exploring