Bottom sheet
A panel that slides up from the bottom — drag it down or flick it away, like in native apps. Mobile first: full width on phones, a centered panel docked at the bottom on bigger screens.
<button class="btn" data-moey-open="#share">Share</button>
<dialog class="sheet" id="share" aria-labelledby="share-title">
<div class="dialog-header">
<h2 class="dialog-title" id="share-title">Share order</h2>
<button class="btn-close" aria-label="Close"></button>
</div>
<div class="dialog-body">…</div>
<div class="dialog-footer">…</div>
</dialog>
Same parts, events and API as the dialog — open with data-moey-open or Moey.open(), close with the ✕, data-moey-dismiss, Esc or by dragging it down. A click above it closes it only with data-moey-close-outside="true" (examples). With moey.js you can also:
- Drag to close — grab the handle, the header or the footer and pull it down. It closes when pulled far enough or flicked; otherwise it springs back. The backdrop fades as you pull.
- Scrolling content scrolls normally; pull down when it's at the top and the sheet follows your finger.
- No accidental taps — a drag never counts as a tap on the button under your finger. Form fields don't start drags.
- Snap points —
data-moey-snap="45%, 100%"opens it at 45% of the screen; drag up to expand, down to shrink and then close. Values are visible heights:%,pxor 0–1. Event:moey:snap. - Static —
data-moey-static: it resists the drag and springs back instead of closing.
Sizes
Sizes set the height; the content scrolls inside when it doesn't fit. On tablets and desktops you can also pick a width (phones always use the full width).
<dialog class="sheet sheet-md"> <!-- half the screen tall -->
<dialog class="sheet sheet-lg"> <!-- three quarters -->
<dialog class="sheet sheet-xl sheet-wide"> <!-- combine height and width -->
<dialog class="sheet sheet-full"> <!-- the whole screen, still drags down to close -->
<style> .order-sheet { --mo-sheet-max-width: 48rem; --mo-sheet-height: 70dvh; } </style> <!-- your own -->
<dialog class="sheet order-sheet">
Dialogs on phones
Every .dialog already turns into a bottom sheet on phones — and it gets the handle and drag-to-close too. So one .dialog is a centered dialog on desktop and a real sheet on mobile, with no extra markup. Use .sheet when you want a sheet on every screen size, .dialog-center to keep a dialog centered on phones.
| Class / attribute | What it does |
|---|---|
.sheet | Bottom sheet; 40rem wide on bigger screens, as tall as its content (up to the screen minus a gap at the top) |
.sheet-sm · -md · -lg · -xl | Height: 35% · 50% · 75% of the screen · as tall as allowed (a gap stays at the top) |
.sheet-full | Fullscreen: edge to edge, no gap, no rounded corners — still drags down to close |
.sheet-narrow · -wide · -stretch | Width on tablets and desktops: 30rem · 56rem · full width |
.sheet-inset | Floats as a rounded card with a gap from the edges |
data-moey-snap | Snap points, e.g. "45%, 100%" |
data-moey-drag="false" | No handle, no dragging |
--mo-sheet-max-width · --mo-sheet-height · --mo-sheet-top-gap | Your own width (bigger screens) · height · space always kept above the sheet (2.5rem) — on the sheet or any parent |
Typing on phones
Phones slide the keyboard over the page instead of resizing it — on iPhone in every browser, and on Android in Chrome, Samsung Internet and most others. A sheet pinned to the bottom of the page would then hide behind the keyboard, or float with a strip of page between them. Moey tracks the part of the screen you can still see, so dialogs, sheets and drawers sit right on the keyboard and slide up with it, like a native app. A sheet that's too tall shrinks and scrolls inside. Nothing to add — it just works.
Fields are 16px on touch screens, so phones never zoom into them, and on iPhone and iPad moey.js also turns that zoom off for a page's own smaller fields (pinch-to-zoom still works). <html data-moey-zoom="keep"> leaves the viewport alone.
Action sheet
A short list of actions, the phone way. The destructive one sits apart.
<button class="btn" data-moey-open="#sx-actions"><i class="mi mi-ellipsis"></i>Order actions</button>
<dialog class="sheet" id="sx-actions" aria-label="Order actions">
<div class="dialog-body dialog-flush">
<div class="list-group list-group-flush">
<button class="list-group-item" data-moey-dismiss>
<i class="mi mi-printer"></i>
<div class="list-group-content">
<div class="list-group-title">Print packing slip</div>
</div>
</button>
<button class="list-group-item" data-moey-dismiss>
<i class="mi mi-copy"></i>
<div class="list-group-content">
<div class="list-group-title">Duplicate</div>
</div>
</button>
<button class="list-group-item" data-moey-dismiss>
<i class="mi mi-archive"></i>
<div class="list-group-content">
<div class="list-group-title">Archive</div>
</div>
</button>
<button class="list-group-item text-red" data-moey-dismiss>
<i class="mi mi-trash-2"></i>
<div class="list-group-content">
<div class="list-group-title">Delete order</div>
</div>
</button>
</div>
</div>
</dialog>
Filters
Phones don’t have room for a filter sidebar — a sheet with Apply works better.
<button class="btn" data-moey-open="#sx-filter"><i class="mi mi-filter"></i>Filters</button>
<dialog class="sheet sheet-md" id="sx-filter" aria-labelledby="sx-filter-title">
<div class="dialog-header">
<h2 class="dialog-title" id="sx-filter-title">Filter orders</h2>
<button class="btn-close" aria-label="Close"></button>
</div>
<form class="contents" method="dialog">
<div class="dialog-body grid grid-cols-1 gap-5">
<fieldset class="grid grid-cols-1 gap-2"><legend class="form-label">Status</legend>
<label class="form-check"><input type="checkbox" checked> Paid</label>
<label class="form-check"><input type="checkbox"> Unpaid</label>
<label class="form-check"><input type="checkbox"> Refunded</label>
</fieldset>
<div class="field">
<label class="form-label" for="sx-from">Placed after</label>
<input class="form-control" id="sx-from" type="date">
</div>
</div>
<div class="dialog-footer">
<button type="reset" class="btn btn-gray btn-ghost">Reset</button>
<button class="btn btn-default">Show results</button>
</div>
</form>
</dialog>
Pick one
Rows of choices; picking one closes the sheet.
<button class="btn" data-moey-open="#sx-sort"><i class="mi mi-arrow-up-down"></i>Sort</button>
<dialog class="sheet" id="sx-sort" aria-labelledby="sx-sort-title">
<div class="dialog-header">
<h2 class="dialog-title" id="sx-sort-title">Sort by</h2>
</div>
<form method="dialog" class="dialog-body dialog-flush">
<div class="list-group list-group-flush">
<label class="list-group-item">
<div class="list-group-content">
<div class="list-group-title">Newest first</div>
</div>
<input class="form-check-input" type="radio" name="sx-sort" checked onchange="this.form.requestSubmit()">
</label>
<label class="list-group-item">
<div class="list-group-content">
<div class="list-group-title">Oldest first</div>
</div>
<input class="form-check-input" type="radio" name="sx-sort" onchange="this.form.requestSubmit()">
</label>
<label class="list-group-item">
<div class="list-group-content">
<div class="list-group-title">Highest total</div>
</div>
<input class="form-check-input" type="radio" name="sx-sort" onchange="this.form.requestSubmit()">
</label>
</div>
</form>
</dialog>