Stacksheet
Sheets you open, push and pop from anywhere in a React app. Side sheets on desktop, bottom sheets on phones, from one API.
@patternmode/stacksheet
Orders
Two sheets deep. The root sheet steps back; Back pops, Escape pops, Close clears the stack.
Reference
States and variants
Set once on the provider, or per sheet when you open it.
Right side
side: "right", width: 420Left side
side: "left"Bottom sheet
side: "bottom"Snap points
snapPoints: [0.4, 0.75]Fitted height
height: "fit"Non-modal
modal: false, showOverlay: false
Install and use
Create the stack once, wrap the app in its provider, then open sheets from any component.
npm i @patternmode/stacksheet motionimport { createStacksheet } from "@patternmode/stacksheet";
import "@patternmode/stacksheet/styles.css";
const { StacksheetProvider, useSheet } = createStacksheet<{
Settings: { title: string };
}>();
function OpenSettings() {
const { open } = useSheet();
return (
<button onClick={() => open("Settings", "settings", { title: "Settings" })}>
Open
</button>
);
}Examples
Placement
Behaviour
Layout
Core API
createStacksheet
Creates an isolated sheet stack instance.
config- StacksheetConfigSide, width, height, modal behavior, drag settings, snap points, and spring presets.
StacksheetProvider- ComponentWraps the app and renders the stack portal. Pass registered sheets and optional class overrides.
useSheet- HookReturns open, push, navigate, replace, swap, pop, and close actions.
options- SheetPresentationOptionsPer-Sheet options, the last argument to open, push, replace and navigate: ariaLabel, and height ("full" or "fit"; fit sizes a bottom Sheet to its content, up to 85dvh).
Sheet
Composable Sheet Parts for custom layouts.
Header / Body / Footer- ComponentsSheet regions with scroll and drag handling.
Back / Close- ComponentsBuilt-in navigation controls for nested stacks.
Read the package README for callbacks, snap points, accessibility, and styling details.
Keyboard and accessibility
What it handles without extra wiring.
- Escape
- Pops the top sheet. Turn off with closeOnEscape: false.
- Focus
- Each sheet is a dialog. Focus moves in on open and returns to the opener on close.
- ariaLabel
- Names the dialog. Defaults to "Sheet dialog"; set it per sheet.
- Reduced motion
- Sheets crossfade instead of sliding: 200ms in, 150ms out.
Package
- Package
- @patternmode/stacksheet
- Version
- 3.1.1
- Needs
- react, react-dom, motion
- Licence
- MIT