Bottom Sheet

The Bottom Sheet component provides a mobile-friendly panel that slides up from the bottom of the screen. It supports snap points, swipe gestures, and modal mode with backdrop.

Installation

npm install @duskmoon-dev/el-bottom-sheet

Usage

import '@duskmoon-dev/el-bottom-sheet/register';
<el-dm-bottom-sheet id="my-sheet" modal>
  <span slot="header">Sheet Title</span>
  <p>Sheet content goes here.</p>
</el-dm-bottom-sheet>

<el-dm-button onclick="document.querySelector('#my-sheet').show()">Open Sheet</el-dm-button>

Live Demo

Bottom Sheet Demo

Open Bottom SheetExample Bottom Sheet

This is a bottom sheet component. You can drag the handle to dismiss it or click outside.

It works great on mobile devices with touch gestures!

Close

Snap Points

Configure multiple height snap points:

Snap Points

Open with Snap PointsSnap Points Demo

Drag this sheet to snap to 25%, 50%, or 100% of the viewport height.

Try swiping up and down to see the snap behavior.

Persistent Sheet

Prevent dismissal via swipe or backdrop click:

Persistent Sheet

Open Persistent SheetPersistent Sheet

This sheet cannot be dismissed by clicking outside or swiping down.

Close Button Required

Properties

PropertyTypeDefaultDescription
openbooleanfalseWhether the bottom sheet is open
modalbooleanfalseWhether to show backdrop and trap focus
persistentbooleanfalsePrevent dismiss by outside click or swipe down
snap-pointsstring'100%'Comma-separated list of snap point heights (e.g., “25%,50%,100%“)

Methods

MethodDescription
show()Opens the bottom sheet
hide()Closes the bottom sheet

Slots

SlotDescription
defaultMain sheet content
headerHeader content above the drag handle

Events

EventDetailDescription
open-Fired when sheet opens
close-Fired when sheet closes
snap{ height: string, index: number }Fired when sheet snaps to a point

Event Handling

const sheet = document.querySelector('el-dm-bottom-sheet');
sheet.addEventListener('open', () => {
  console.log('Sheet opened');
});
sheet.addEventListener('close', () => {
  console.log('Sheet closed');
});
sheet.addEventListener('snap', (e) => {
  console.log('Snapped to:', e.detail.height);
});

CSS Parts

PartDescription
wrapperThe outer wrapper element
sheetThe sheet container
backdropThe backdrop overlay (modal mode)
handle-areaThe drag handle area
handleThe drag handle bar
headerThe header section
contentThe content wrapper

Accessibility

  • Uses role="dialog" for the sheet
  • Uses aria-modal when in modal mode
  • Escape key closes non-persistent sheets
  • Focus is trapped within the sheet when modal
  • Body scroll is disabled when sheet is open
  • Safe area padding for notched devices