Bottom Sheet
A panel anchored to the bottom that can be dragged between collapsed, half and full heights.
AI prompt
Create a 280x260px phone-like area with placeholder map content behind a bottom sheet. The sheet is absolutely positioned at the bottom with border radius 16px on top, white background, 1px border, and a centered handle button (40x4px bar inside a 44px tall hit area, touch-action none, aria-label "Resize sheet") above a title "Nearby" and three list rows. Define snap heights of 64px, 50% and 90% of the container. Pointer events on the handle change the sheet height by the drag delta (clamped between 64px and 90%) with transitions disabled while dragging; on release, snap to the nearest snap height with a 300ms cubic-bezier(.2,.7,.2,1) height transition. Pressing Enter or Space on the handle moves to the next snap height, looping back to the first. Expose the current state in aria-valuetext through role "slider" semantics or in a polite live region. Under prefers-reduced-motion snap without transition.About this pattern
Definition
A surface docked to the bottom of the screen. Dragging its handle changes its height, and on release it snaps to the nearest of several preset heights.
Purpose & UX principles
- Shows supporting content (maps, filters, playlists) while keeping the main view visible.
- Snap points make the result predictable; the handle is the only draggable area so inner content can still scroll.
- The handle is also a button: Enter cycles through the snap heights for people who cannot drag.
Interaction states
- Collapsed, half, full, dragging (no transition), focus-visible on the handle.
Motion specification
- Release snaps with a 300ms cubic-bezier(.2,.7,.2,1) height transition.
- Dragging tracks the pointer without delay.
- Reduced motion: snaps instantly.
Responsive behaviour
- Snap heights are relative to the container: collapsed 64px, half 50%, full 90%.
- On wide screens the sheet can become a fixed-width panel.
Code
<div class="phone" id="phone">
<div class="map" aria-hidden="true"></div>
<section class="sheet" id="sheet" aria-label="Nearby places">
<button class="grab" id="grab" aria-label="Resize sheet"><i></i></button>
<h3>Nearby</h3>
<ul><li>Cafe Meridian<small>120 m</small></li><li>North Library<small>340 m</small></li><li>Green Market<small>600 m</small></li></ul>
</section>
</div>:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
.phone{position:relative;width:min(280px,100%);height:260px;border:1px solid var(--line);border-radius:18px;overflow:hidden;background:var(--bg)}
.map{position:absolute;inset:0;background:repeating-linear-gradient(45deg,#e8e8e4 0 12px,#efefeb 12px 24px)}
.sheet{position:absolute;left:0;right:0;bottom:0;height:64px;background:var(--surface);border:1px solid var(--line);border-bottom:0;border-radius:16px 16px 0 0;overflow:hidden;transition:height .3s cubic-bezier(.2,.7,.2,1)}
.sheet.drag{transition:none}
.grab{display:grid;place-items:center;width:100%;height:30px;background:none;border:0;cursor:grab;touch-action:none}
.grab i{width:40px;height:4px;border-radius:2px;background:#cfcfca}
.grab:focus-visible{outline:2px solid var(--accent);outline-offset:-3px;border-radius:12px}
h3{font-size:14px;font-weight:600;padding:0 16px 6px}
ul{list-style:none}
li{display:flex;justify-content:space-between;padding:11px 16px;border-top:1px solid var(--line);font-size:13px}
li small{color:var(--muted)}
@media (prefers-reduced-motion:reduce){.sheet{transition:none}}const phone=document.getElementById('phone'),sheet=document.getElementById('sheet'),grab=document.getElementById('grab');
const H=()=>phone.clientHeight,snaps=()=>[64,H()*.5,H()*.9];let idx=0,y0=0,h0=0,drag=false;
const set=i=>{idx=i;sheet.style.height=snaps()[i]+'px';};
grab.addEventListener('pointerdown',e=>{drag=true;y0=e.clientY;h0=sheet.offsetHeight;sheet.classList.add('drag');grab.setPointerCapture(e.pointerId);});
grab.addEventListener('pointermove',e=>{if(!drag)return;sheet.style.height=Math.max(64,Math.min(H()*.9,h0+(y0-e.clientY)))+'px';});
const up=e=>{if(!drag)return;drag=false;sheet.classList.remove('drag');const h=sheet.offsetHeight,moved=Math.abs(e.clientY-y0)>4;if(!moved){set((idx+1)%3);return;}
let b=0;snaps().forEach((s,i)=>{if(Math.abs(s-h)<Math.abs(snaps()[b]-h))b=i;});set(b);};
grab.addEventListener('pointerup',up);grab.addEventListener('pointercancel',up);
grab.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();set((idx+1)%3);}});One complete HTML file. Save it and open it in a browser.
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Bottom Sheet — demo</title>
<style>
:root{--bg:#F1F1EF;--surface:#fff;--surface-2:#F7F7F5;--line:#E0E0DC;--text:#171717;--muted:#6f6f6f;--accent:#171717;--accent-ink:#fff;--danger:#d92d20}
*{box-sizing:border-box;margin:0}
html,body{height:100%}body{background:var(--bg);color:var(--text);font:15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Inter,Roboto,sans-serif;-webkit-font-smoothing:antialiased}.stage{min-height:100%;display:grid;place-items:center;padding:24px}button,input,select,textarea{font-family:inherit}@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
.phone{position:relative;width:min(280px,100%);height:260px;border:1px solid var(--line);border-radius:18px;overflow:hidden;background:var(--bg)}
.map{position:absolute;inset:0;background:repeating-linear-gradient(45deg,#e8e8e4 0 12px,#efefeb 12px 24px)}
.sheet{position:absolute;left:0;right:0;bottom:0;height:64px;background:var(--surface);border:1px solid var(--line);border-bottom:0;border-radius:16px 16px 0 0;overflow:hidden;transition:height .3s cubic-bezier(.2,.7,.2,1)}
.sheet.drag{transition:none}
.grab{display:grid;place-items:center;width:100%;height:30px;background:none;border:0;cursor:grab;touch-action:none}
.grab i{width:40px;height:4px;border-radius:2px;background:#cfcfca}
.grab:focus-visible{outline:2px solid var(--accent);outline-offset:-3px;border-radius:12px}
h3{font-size:14px;font-weight:600;padding:0 16px 6px}
ul{list-style:none}
li{display:flex;justify-content:space-between;padding:11px 16px;border-top:1px solid var(--line);font-size:13px}
li small{color:var(--muted)}
@media (prefers-reduced-motion:reduce){.sheet{transition:none}}
</style></head>
<body><div class="stage">
<div class="phone" id="phone">
<div class="map" aria-hidden="true"></div>
<section class="sheet" id="sheet" aria-label="Nearby places">
<button class="grab" id="grab" aria-label="Resize sheet"><i></i></button>
<h3>Nearby</h3>
<ul><li>Cafe Meridian<small>120 m</small></li><li>North Library<small>340 m</small></li><li>Green Market<small>600 m</small></li></ul>
</section>
</div>
</div>
<script>
const phone=document.getElementById('phone'),sheet=document.getElementById('sheet'),grab=document.getElementById('grab');
const H=()=>phone.clientHeight,snaps=()=>[64,H()*.5,H()*.9];let idx=0,y0=0,h0=0,drag=false;
const set=i=>{idx=i;sheet.style.height=snaps()[i]+'px';};
grab.addEventListener('pointerdown',e=>{drag=true;y0=e.clientY;h0=sheet.offsetHeight;sheet.classList.add('drag');grab.setPointerCapture(e.pointerId);});
grab.addEventListener('pointermove',e=>{if(!drag)return;sheet.style.height=Math.max(64,Math.min(H()*.9,h0+(y0-e.clientY)))+'px';});
const up=e=>{if(!drag)return;drag=false;sheet.classList.remove('drag');const h=sheet.offsetHeight,moved=Math.abs(e.clientY-y0)>4;if(!moved){set((idx+1)%3);return;}
let b=0;snaps().forEach((s,i)=>{if(Math.abs(s-h)<Math.abs(snaps()[b]-h))b=i;});set(b);};
grab.addEventListener('pointerup',up);grab.addEventListener('pointercancel',up);
grab.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){e.preventDefault();set((idx+1)%3);}});
</script>
</body></html>