Sheet
One component that is a snap-point bottom sheet on phones and morphs — live, in place, while open — into a side drawer or centered dialog past the breakpoint, with spring-physics snaps, drag and flick gestures, a dismiss policy, entrance and exit effects, and an optional container-transform flight out of the trigger that opened it.
This piece is a wrapper, not a port: it renders the real <dialog-panel> and <sheet-panel> custom elements from @magic-spells/sheet and binds attributes to them. The value here is motion — spring integration, the scroll-chain handoff that decides whether a finger belongs to the sheet or to a nested scroller, the profile morph across the breakpoint — 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, an allowed swipe, 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 sheet
Like 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.
npm install @magic-spells/sheet # Yarn 1 only — npm 7+ and pnpm install the peer for you # yarn add @magic-spells/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; sheet.css layers the panel geometry, the handle 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/sheet/css" layer(components);
Order matters — dialog-panel first, because 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 Sheet from '@/components/ui/Sheet.pzl';
<Sheet open={ cartOpen } title="Your cart" @hide={ closeCart }>
<CartLines/>
<Button slot="footer" @press={ checkout }>Checkout</Button>
</Sheet>
// open is EDGE-TRIGGERED: only a change to it acts. The sheet dismisses
// itself on Escape, a backdrop tap, an allowed swipe, 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 = {
closeCart: () => this.setData('cartOpen', false),
};Saying nothing about position gets the responsive default: a snapping bottom sheet on a phone, and past the breakpoint a centered dialog sized to its own content. Pass desktopPosition="bottom" to keep it welded to the bottom edge on desktop too.
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 swiped away while your state still says it is open.
Controlled snaps — stock header
Different mobile and desktop positions
Positions — same at every width
Card mode vs edge
Entrance and exit effects
Growing out of the thing you tapped
A sheet that may not be waved away
Spring override
Custom header and a close button
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.positionMobile profile: bottom, left, right, or center. Default bottom.modeMobile geometry: edge or card. Default edge. Ignored by a center position at every width.breakpointPixel width where the desktop profile takes over. Default 768.desktopPositionDesktop position. Falls back to position — except a bottom sheet, which defaults to center so a wide panel sizes to its content instead of standing 85vh tall. Pass "bottom" to keep it bottom.desktopModeDesktop mode. Always card unless set — it does NOT inherit mode.effectEntrance: slide, fade-scale, or slide-fade. Default slide.exitEffectExit effect; falls back to effect.desktopEffectDesktop entrance; falls back to effect, except a centered desktop profile, which defaults to fade-scale.desktopExitEffectDesktop exit; falls back to exitEffect, then desktopEffect.snapPointsSpace-separated CSS heights, or an array of them. A MOBILE BOTTOM prop only — every other profile sizes itself by measurement. Default "85vh".initialSnapZero-based snap index the sheet opens at. Default: the largest.snapOptional-controlled snap index. Only a change 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. Pair with @snapChange. It does not seed the opening index — use initialSnap.dismissWhich of swipe, backdrop, escape may dismiss. Absent or "all" opens all three; "none" refuses all three. A refused sheet still tracks your finger and springs back.maxDisplayWidthLargest viewport width where opening is allowed. Above it show() refuses silently, so open={true} there leaves the page out of sync until you flip it back.spring"attraction friction" entrance override, both dials in (0, 1).morphTriggerCSS selector or Element the panel grows out of and shrinks back into, and the focus-return target. Without it the sheet still returns focus — document.activeElement at open time is used — it simply does not morph.showGrabberDefault true. false zeroes the handle pill and the room reserved for it. CSS only; the drag surfaces are unaffected. The component already hides it on a fine pointer and on the desktop profile.classMerged onto the sheet-panel element.backdropClassMerged onto the dialog-backdrop element.styleMerged onto sheet-panel after the piece's own classes. It must not CHANGE between renders — the component writes --sheet-active-size into that same attribute every frame.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 swipe. Flip open back to false here.@show()The entrance settled and the native dialog is in the top layer.@snapChange(index)A release committed a different snap; fires on commit, never mid-drag.Slots
headerFills 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 sheet-footer, pinned below the content and hidden while empty. Takes one direct child, so wrap multiple buttons in a div that carries the slot attribute.defaultUntagged children become sheet-content, the scrollable region.CSS custom properties
Everything the ported piece exposed as numeric props — exit runway, morph duration and easing, the trigger-return pop, the blob's stacking level — 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 (--sheet-panel-background, --sheet-handle-color, and the two overlay tokens) and leaves the rest at the component's defaults:
--sheet-active-sizeFixed width of a left or right sheet (default min(26rem, 90vw)), and the active snap height of a mobile bottom sheet.--sheet-center-widthWidth of a center dialog; its height always follows its content.--sheet-panel-border-radiusExposed corner radius in edge mode (25px). --sheet-card-border-radius (20px) and --sheet-card-margin (12px) do the same for card mode.--sheet-content-paddingContent inset (20px). --sheet-footer-padding follows it, plus the safe area.--sheet-morph-durationProfile-morph duration (600ms) AND the trigger-morph gate: 0 disables the morph entirely, which is what prefers-reduced-motion sets.--sheet-exit-cushionHow far past its edge a dismissal carries the panel (28px). Raise it to about your shadow blur if the panel leaves a halo.--sheet-trigger-return-durationThe pop a trigger plays when a close did not morph back into it (280ms).--sheet-panel-z-indexStacking of the dialog (1001), one above dialog-panel's scrim; --sheet-blob-z-index (1002) is the morph blob. Raise the trio together.The full list lives in the component's README — these are the ones a piece consumer reaches for most.