Bottom sheet
A modal sheet that rises from the bottom edge and rests at configurable viewport-height detents.
import { BottomSheet } from '@uthereal/ui/bottom-sheet'Bottom sheet playground
Overview
BottomSheet renders a modal surface anchored to the bottom edge that rests at one to four viewport-height stops (detents). It requires a title, accepts an optional description, and renders children inside a body beneath a draggable header with a grabber handle and corner close button. While open, focus lands on the sheet and stays trapped inside, background content is inert (except live regions), page scroll locks, and closing returns focus to the trigger or the previously focused element.
The surface caps its width at min(100%, 36rem) centered in the viewport, extends 160px below the fold so upward rubber-banding never exposes a gap, and shows a scroll hairline under the header once the body scrolls. A single MotionValue drives both the sheet's vertical offset and the backdrop opacity with zero per-frame React re-renders.
Use BottomSheet for secondary tasks where a partial peek is useful before committing to the full view: trip details, share options, filters, or media queues. Use Dialog for interrupting decisions and Drawer for edge-anchored side panels on wide layouts.
Usage
'use client'
import { useState } from 'react'
import { BottomSheet } from '@uthereal/ui/bottom-sheet'
import { Button } from '@uthereal/ui/button'
export function TripDetailsSheet() {
return (
<BottomSheet
title="Trip details"
description="Flight LX 318 · Zurich to London Heathrow."
triggerLabel="Show trip details"
>
<p>Boarding starts at 14:15 at Gate A42.</p>
</BottomSheet>
)
}
export function ControlledFilterSheet() {
const [open, setOpen] = useState(false)
const [detent, setDetent] = useState(0)
return (
<>
<Button
label="Open filters"
variant="outline"
onAction={() => setOpen(true)}
/>
<BottomSheet
title="Filters"
open={open}
onOpenChange={setOpen}
detents={[0.35, 0.7, 0.95]}
detent={detent}
onDetentChange={setDetent}
>
<p>Current stop index: {detent}</p>
</BottomSheet>
</>
)
}Omit triggerLabel (or pass renderTrigger={null}) to control visibility solely through open and onOpenChange.
Examples
Detents
detents accepts one to four fractions of the viewport height between 0.15 and 0.98. Values sort ascending on resolution so defaultDetent, detent, and onDetentChange always index the sorted order.
| Detents | Stops | Typical use |
|---|---|---|
[0.6] | Single | Short action lists or summaries without peek expansion. |
[0.45, 0.92] | Two | Default peek-and-expand view for details or filters. |
[0.35, 0.7, 0.95] | Three | Rich inspectors or maps that benefit from a mid stop. |
Behavior and labels
Set defaultDetent to open at a higher stop, customize expandLabel, collapseLabel, and closeLabel for localized assistive text, or set motion="none" for immediate snap transitions with dragging disabled.
Gestures
With motion enabled (default), one MotionValue controls vertical position and feeds a useTransform backdrop dim (1.0 at the tallest detent, 0.78 at the smallest detent, 0 when closed):
| Gesture | Effect |
|---|---|
| Drag header or grabber downward (mouse, pen, or touch) | Follows the pointer 1:1 toward lower detents and dismissal. |
| Drag upward past the tallest detent | Applies iOS-style rubber-band resistance approaching 120px; releases at zero velocity. |
| Release after dragging | Projects position 0.2s ahead (y + v * 0.2) and snaps to the nearest detent or close. |
Flick faster than 320 px/s | Advances at least one detent in the flick direction; flicking down from stop 0 closes. |
| Touch drag on body below the tallest detent | Drags the sheet directly instead of scrolling the body. |
| Touch drag on body at the tallest detent | Scrolls the body natively; pulling down from scrollTop === 0 hands back to sheet drag. |
| Wheel scroll down on body below the tallest detent | Expands the sheet to its tallest detent before scrolling content. |
| Press interactive control in header (excluding grabber) | Ignored by the header pointer handler so buttons and links activate normally. |
Collapsing below the tallest detent resets body scroll to the top so the peek always shows the start of the content. Catching a leaving sheet mid-exit reverses it from its current position without flashing.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
titleRequired | string— | Heading of the sheet, required: it names the sheet for assistive technology. |
description | string— | Supporting text under the title, announced when it opens. |
detents | number[]Default: [0.45,0.92] | Resting heights as fractions of the viewport height, 0.15 to 0.98 each, one to four of them. They sort ascending; the sheet opens at defaultDetent and never grows past the largest. The default [0.45, 0.92] peeks at less than half the screen and expands to most of it. |
defaultDetent | integerDefault: 0 | Index into the sorted detents the sheet opens at. 0 (the default) is the smallest; the keyboard, a drag or scrolling moves between detents. |
triggerLabel | string— | Label of the default trigger button. Omit it when the sheet opens through state alone. |
closeLabel | stringDefault: "Close" | Accessible name of the close button, e.g. "Close sheet". |
expandLabel | stringDefault: "Expand sheet" | Accessible name of the grabber handle while collapsed, e.g. "Expand sheet". |
collapseLabel | stringDefault: "Collapse sheet" | Accessible name of the grabber handle while expanded, e.g. "Collapse sheet". |
defaultOpen | booleanDefault: false | Initial open state. Later argument edits do not reset an existing instance. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | BottomSheetTheme— | Color mode, accent, and modal tokens (padding, titleSize, backdropBlur, sheetRadius, surfaceRadius, overlay, borderStrong). See Theming for all keys and defaults. |
motion | none | subtle | expressiveDefault: "subtle" | Detent animation preset. System reduced-motion preferences take precedence. |
motionOptions | BottomSheetMotionOptions— | The detent transition, Arc's smooth spring by default; a release keeps its velocity into the next detent or the exit. Durations are milliseconds. |
dir | ltr | rtl— | Reading direction. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
ref | Forwarded to the portalled sheet surface HTMLDivElement. |
children | Sheet body content rendered below the header. |
open / onOpenChange(open) | Controlled open state and change callback. |
detent / onDetentChange(index) | Controlled resting detent index (into sorted detents) and change callback. |
renderTrigger(props, state) | Custom trigger renderer; spread props onto a focusable element. Pass null to omit the trigger. |
renderIcon(name, context) | Custom icon renderer for slot: 'trigger' or slot: 'close'. Keep icons decorative. |
preset | Application defaults merged below instance props. |
tokens | --ui-* CSS variables applied after the typed theme on the trigger and surface. |
className | Class name appended to the sheet surface. |
portalContainer | Portal target, such as an element inside a native <dialog> top layer. |
Keyboard & accessibility
| Key | Context | Interaction |
|---|---|---|
Enter, Space | Trigger | Open the sheet. |
Enter, Space | Grabber button | Toggle between the smallest and tallest detent (multi-detent sheets). |
ArrowUp / ArrowDown | Grabber button | Step up or down one detent. |
Home / End | Grabber button | Jump to the tallest or smallest detent. |
ArrowDown, PageDown, Space | Sheet or body | Expand to the tallest detent first, then scroll the body down. |
ArrowUp, PageUp, Shift+Space | Sheet or body | Scroll the body up. |
Tab / Shift+Tab | Inside sheet | Move focus inside the sheet; auto-expands when focusing below the fold. |
Escape | Inside sheet | Close the sheet and return focus to the trigger or previous element. |
The surface renders with role="dialog" and aria-modal="true", labelled by title and described by description. Multi-detent sheets expose the grabber as a focusable <button> with aria-expanded and expandLabel / collapseLabel; single-detent sheets render the bar as decorative so screen readers do not announce a no-op toggle. A polite live region (role="status", aria-live="polite") announces "Sheet expanded", "Sheet collapsed", or "Sheet at N percent height" whenever the resting detent changes.
Nested overlays opened inside a sheet portal into it through LayerContext and stack above it, with Escape closing the topmost layer first. All layout, borders, padding, and corner radii use logical CSS properties and mirror under dir="rtl". Under forced-colors: active, the sheet border, scroll hairline, and grabber bar retain visible ButtonText contrast.
Motion and theming
Detent settling and dismissal run on Arc's smooth spring (0.4s, bounce 0, zero overshoot) by default, preserving finger velocity on release. motion="expressive" uses the morph spring (0.42s, bounce 0.16), and motionOptions.transition overrides the spring or tween (durations in milliseconds). A ResizeObserver tracks dynamic viewport height (dvh) changes from mobile toolbars or rotation and refits the sheet to its active detent without jarring jumps.
Under prefers-reduced-motion: reduce, detents jump immediately without travel, open and close crossfade opacity over 120 ms, backdrop blur is removed, and CSS transitions turn off. Setting motion="none" snaps open, close, and detent changes immediately (0 ms) and disables pointer and touch dragging.
| Theme token | CSS variable | Default | Role |
|---|---|---|---|
padding | --ui-modal-padding | 24px | Header and body padding scale (16px inline ≤640 px). |
titleSize | --ui-modal-title-size | 18px | Heading font size. |
backdropBlur | --ui-modal-backdrop-blur | 0px | Optional backdrop blur radius (0 disables blur). |
sheetRadius | --ui-modal-sheet-radius | 22px | Top corner radius (18px on viewports ≤640 px). |
overlay | --ui-overlay | theme | Backdrop tint color driven by sheet position. |
borderStrong | --ui-border-strong | theme | Resting grabber bar fill. |
surfaceRaised | --ui-surface-raised | theme | Sheet surface background color. |
theme also accepts mode, accent, and core color, border, typography, and shadow tokens. Trigger and close buttons inherit recipe, mode, accent, motion, dir, and tokens.
Composition
In an agent composition, BottomSheet is a container whose children render inside its body, and its resting detent index is host state.
{
"type": "BottomSheet",
"props": {
"title": "Trip details",
"description": "Flight LX 318 · Zurich to London Heathrow.",
"triggerLabel": "Show trip details",
"detents": [0.45, 0.92]
},
"children": ["boarding-summary", "gate-info"]
}