Bottom Sheet
A native-dialog sheet that rises from the bottom edge, dragged and flicked with a finger, optionally resting on snap points that settle on a velocity-aware spring, with a pinned footer and a scrim that tracks the dismissal rather than the drag.
This piece is a wrapper, not a port: it renders the real <dialog-panel> and <bottom-sheet> custom elements from @magic-spells/bottom-sheet and binds attributes to them. The value here is motion — the gesture policy that decides whether a finger belongs to the sheet or to the list inside it, the velocity rules that tell a dismissal from a resize — and none of that is worth forking. The design-system bridge is four CSS custom properties.
The sheet closes itself on Escape, a backdrop tap, a downward flick, or any data-action-hide-dialog button, and reports through @hide. Your job is to flip open back to false there — see Usage.
Installation
Copy the piece into your app — it compiles with your build and the code is yours:
puzzle add piece bottom-sheet
Like Sheet and Scroll Stack, this piece has a runtime dependency: the web component it wraps. @magic-spells/dialog-panel is a peer that npm 7+ and pnpm install for you; Yarn 1 only warns, so install it explicitly there. If you already use the Sheet piece it is the same peer, installed once.
npm install @magic-spells/bottom-sheet @magic-spells/dialog-panel # Yarn 1 only — npm 7+ and pnpm install the peer for you # yarn add @magic-spells/bottom-sheet @magic-spells/dialog-panel
Then merge both stylesheets into your app's style entry (app/styles/styles.css). dialog-panel owns the dialog and overlay transport; bottom-sheet.css layers the panel geometry, the grabber, the snap heights and the scrim on top of it. Without them the sheet is an unstyled full-bleed native dialog:
/* app/styles/styles.css */ @import "tailwindcss"; @import "@magic-spells/dialog-panel/css" layer(components); @import "@magic-spells/bottom-sheet/css" layer(components);
Order matters — dialog-panel first, because bottom-sheet.css deliberately overrides several of its rules. So does layer(components): both stylesheets use plain element selectors, and an unlayered import would outrank every Tailwind utility you put on the panel.
Requires the pieces.css tokens merged into your app styles (see Introduction).
Usage
import BottomSheet from '@/components/ui/BottomSheet.pzl';
<BottomSheet open={ filtersOpen } title="Filters" @hide={ closeFilters }>
<FilterList/>
<Button slot="footer" @press={ apply }>Apply</Button>
</BottomSheet>
// open is EDGE-TRIGGERED: only a change to it acts. The sheet dismisses
// itself on Escape, a backdrop tap, a downward flick, or any
// [data-action-hide-dialog] descendant, then reports through @hide —
// where you flip open back to false so the next open is a fresh edge.
// parent script
events = {
closeFilters: () => this.setData('filtersOpen', false),
};open is edge-triggered: only a change to it acts. That is what makes a self-closing sheet safe — an unrelated re-render never re-opens a sheet the user just flicked away while your state still says it is open.
Coming from the ported piece: @close(reason) is gone. The sheet reports through @hide, whose detail carries result and triggerElement — result names the button that closed it and is null for every dismissal. dismissible has no equivalent upstream; a bottom sheet is always dismissible.
Binary sheet
Inset, and the settle without a spring
A footer that answers
Custom header and the grabber
Reference
Props
openControlled, and EDGE-TRIGGERED: only a change acts. true opens, false closes. An unrelated re-render never re-opens a sheet the user already dismissed.titleHeading text rendered by the stock header, which also generates its id and wires aria-labelledby. Ignored once the header slot is filled.labelledbyId of the labelling heading when the header slot is filled.snapPointsComma- or space-separated percentages of the viewport height, or an array of numbers. Each is a HEIGHT, which is what pins the footer at every rung. Sorted and deduped; anything outside 0–100 is dropped. Omit for the two-state sheet.snapOptional-controlled resting snap in dvh percent — a VALUE, not an index. Set at mount it is also the opening rung; only a change later calls snapTo(), and a change that writes back a rung the sheet itself announced through @snapChange is absorbed — a late render can never drag the sheet back to a rung the user already left. Undeclared values are ignored, not clamped. Pair with @snapChange.spring"attraction,friction" override for the snap settle, both dials in (0, 1); "none" settles on the CSS curve instead. Governs the SETTLE only — opening, closing and every sheet without snapPoints stay on plain transitions.insetDetaches the sheet from all three edges and rounds every corner. CSS only; the off-screen position is corrected so the exit still clears the gap.maxDisplayWidthLargest viewport width where the sheet may open. It also closes an open sheet when a resize crosses the limit. Above it show() returns early and no event fires.showGrabberDefault true. false zeroes the handle pill. CSS only; the header is a drag surface either way.classMerged onto the bottom-sheet element.backdropClassMerged onto the dialog-backdrop element. Inert on bottom-sheet 2.0.2, which still paints the scrim on the dialog's native ::backdrop.styleMerged onto the bottom-sheet element after the piece's own classes.Callbacks
@hide(detail)The exit finished. detail is { result, triggerElement }: result is the data-result of the [data-action-hide-dialog] button that closed it, and null for Escape, a backdrop tap or a flick. Flip open back to false here.@show()The entrance settled and the native dialog is in the top layer.@snapChange(value)A release committed a different snap; the value is the new resting rung in dvh percent. Fires on commit only, never mid-drag, and never when the sheet settles back where it started.Slots
headerFills bottom-sheet-header, replacing the title heading entirely; a filled header brings its own heading and points labelledby at it. The grabber is a pseudo-element and survives it. Always a drag surface.footerFills bottom-sheet-footer, pinned below the content at every snap and hidden while empty. Also a drag surface. Takes one direct child, so wrap multiple buttons in a div that carries the slot attribute.defaultUntagged children become bottom-sheet-content, the scrollable region.CSS custom properties
Everything the ported piece exposed as tuning constants — durations, easings, the hidden-offset overshoot, the inset gaps — is a custom property on the component, tunable from your own CSS with no prop at all. The piece bridges four of them onto the design tokens (--bs-panel-background, --bs-handle-color, and the two overlay tokens) and leaves the rest at the component's defaults:
--bs-panel-max-heightCap on a sheet with no snap points (85vh). Inert once snapPoints is set — the tallest snap is the cap.--bs-panel-border-radiusTop corner radius (25px), or all four with inset.--bs-content-paddingHorizontal header/content inset (20px). --bs-content-padding-block adds a vertical one; --bs-footer-padding follows it, plus the safe area.--bs-panel-hidden-offsetExtra travel past the bottom edge when hidden (20px), so the close does not read as cut short. Applied to the hidden, showing and hiding transforms alike.--bs-transition-durationOpen, close and backdrop fade (400ms), on --bs-transition-timing. The snap settle keeps its own pair, --bs-snap-duration and --bs-snap-timing, which only reach the sheet with spring="none".--bs-panel-inset-xSide gap in inset mode (12px); --bs-panel-inset-bottom (12px) is the gap below, added on top of the safe area.--bs-panel-bleedOff-screen fill of panel colour below an edge-anchored sheet (60px), so an upward rubber-band drag never reveals the page beneath.--bs-footer-backgroundFooter fill (transparent, so the panel shows through). --bs-handle-width sizes the grabber the piece already colours.The full list lives in the component's README — these are the ones a piece consumer reaches for most.
Known gaps
Touch cannot hand a scroll to the sheet mid-gesture. The content scrolls natively, and Pointer Events do not let a gesture change owner once the browser has started panning with it, so reaching the top of a list and continuing into a drag takes two gestures: lift, then drag. A mouse or pen can reverse mid-gesture. This is the component's deliberate trade, not a piece limitation.
A keyboard activation of a data-action-hide-dialog button closes the sheet but reports result: null. A pointerless click carries coordinates of 0,0, which dialog-panel reads as a tap outside the dialog before the delegated handler runs. A mouse click reports the data-result correctly. Fix pending upstream in dialog-panel.
On the currently published pair — bottom-sheet 2.0.2 with dialog-panel 2.0.1 — two overlays paint at once, so the scrim reads darker than the 50% the piece sets: 2.0.2 still paints its scrim on the dialog's native ::backdrop and tries to hide dialog-panel's own backdrop element with a rule that loses on specificity. It is cosmetic, backdropClass has nothing visible to style until it is settled, and the component's main branch already moves the scrim onto the element.
An unfilled footer slot leaves no visible bar, but the component's :has() rule still sees the empty element and drops the dialog's own safe-area padding — so a footerless sheet loses that inset on a notched phone.
maxDisplayWidth refuses the open silently: show() returns early and no event fires, so opening above the ceiling leaves your state out of sync until you flip the flag back yourself.