Menu

React Bottom Sheet for the Web: Snap Points, Drag, Keyboard
📰

React Bottom Sheet for the Web: Snap Points, Drag, Keyboard

DEV Community: frontend·Serban Dan Rusu·4 days ago
#Jcv06cXp
#devtofrontend#devto#dev#sheet#drawer
Reading 0:00
15s threshold

TL;DR

A React bottom sheet for the web is a draggable dialog pinned to the bottom of the screen, so build it on a DOM dialog primitive: Base UI's Drawer (maintained) or vaul (unmaintained per its README, still the most complete option on Radix). Pass snap points as fractions from 0 to 1 in a stable array, let the body scroll only at the last point, raise the sheet above the on-screen keyboard with the visualViewport API, and pad the part that touches the bottom edge with env(safe-area-inset-bottom). The free Wingo UI Drawer does all of this on top of vaul 1.1.2.

Search for a React bottom sheet and many of the top results are React Native packages such as @gorhom /bottom-sheet, which reach the browser only through React Native Web. This guide is about the React bottom sheet web apps need: a real dialog in the DOM, pointer events, position: fixed , an on-screen keyboard that covers half the screen and a home indicator under your Save button.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.