@gridui/bottom-sheet
v1.3.1
Published
GridUI React keyboard-aware bottom sheet
Readme
@gridui/bottom-sheet
A modal bottom sheet with the existing GridUI surface, focus and motion rules. Load Theme, then BottomSheet styles (which include Overlay). The application owns labels, content, state persistence and deciding when to use a sheet.
import "@gridui/theme/styles.css";
import "@gridui/bottom-sheet/styles.css";
import {
BottomSheet, BottomSheetTrigger, BottomSheetPanel,
BottomSheetTitle, BottomSheetDescription, BottomSheetClose,
} from "@gridui/bottom-sheet";
<BottomSheet>
<BottomSheetTrigger>Filters</BottomSheetTrigger>
<BottomSheetPanel resizeLabel="Sheet height">
<BottomSheetTitle>Filters</BottomSheetTitle>
<BottomSheetDescription>Choose the visible results.</BottomSheetDescription>
<BottomSheetClose>Done</BottomSheetClose>
</BottomSheetPanel>
</BottomSheet>Root accepts open / defaultOpen / onOpenChange. Radix Dialog owns modal
focus, Escape, outside dismissal, scroll locking and return to the trigger.
Title and Description provide dialog semantics; follow Radix's description
contract when deliberately omitting a description. portalContainer can host
the panel within an application's local theme scope.
Panel snapPoints are strictly increasing visible-viewport fractions in (0, 1],
defaulting to [0.5, 0.9]. snapPoint / defaultSnapPoint / onSnapPointChange
control the requested height. Values between allowed points resolve to the
nearest point. Dragging the handle previews a height and commits on release;
cancellation restores the committed value. Escape during a drag cancels it before
dismissing the sheet; window blur, capture loss and changes to snap points or
viewport height also cancel the gesture. Controlled callers can reject changes.
Release projects the current position using recent vertical velocity over a short
180ms horizon. The nearest projected snap is selected; a projected position below
half the smallest point requests closing unless
dismissOnDrag={false}. Scrolling the content never starts a resize gesture.
The labeled handle is a vertical slider: arrows select adjacent heights and Home/End select the limits. Keyboard resizing never dismisses the sheet. Provide a visible close control. Input-method composition keys do not resize the sheet.
The panel tracks its owning window's visual viewport, including soft keyboard height and viewport panning, and includes safe-area padding. Pinch zoom retains the layout viewport contract. Coarse-pointer inputs keep a 1rem minimum font size; applications must preserve the native root font size. Reduced motion removes sheet entrance, exit and resizing transitions.
Styles
Load Theme once. Use @gridui/bottom-sheet/styled for automatic component CSS in
CSS-aware bundlers, or keep the CSS-free root import and load @gridui/bottom-sheet/styles.css.
Both entries expose the same root API. The standalone stylesheet includes component
dependency styles; Theme/reset remain separate. See the
integration guide
for static HTML loading, SSR limits, and avoiding duplicate CSS.
See release history.
Component reference contains focused API pages for each public component.
Set --gridui-overlay-ease-enter and --gridui-overlay-ease-exit on the portal
container or document root to tune panel and backdrop easing. They default to
the Theme ease-out and ease-in curves, respectively.
Reversing the open state mid-animation continues from the displayed vertical
position and backdrop opacity. Drag and snap still control the sheet height.
Shared animation policy and tempo come from MotionConfig in @gridui/motion.
Disabled or reduced-motion policy settles decoration without disabling interaction.
See the motion guide
for CSS scopes, portal behavior, and specialized timing contracts.
Resizing uses the shared interruptible spring value (stiffness 300, damping 34). Regrabbing begins at the rendered height; cancellation returns to the committed point. A stationary release loses stale velocity after 100ms. Keyboard resizing has no gesture velocity and never requests dismissal. Controlled callers may reject a snap; one release produces at most one snap-change request. The spring updates the owned height variable directly, without a React render per frame. Height animation incurs layout work because sheet content must actually resize.
Sizing and density
BottomSheet retains fractional snap points, visual-viewport bounds and independent child controls. Choose size on supplied Button/Input parts; the sheet has no whole-surface size preset.
See the shared sizing contract for native attributes, scope precedence, tokens and target behavior.
