Web · Components
Sheet
Panel that slides in from an edge of the screen: mobile navigation menu, filters, cart, detail panel, bottom sheet, result list over a map.
4 exports
Live example
Preview
Code
Events
- Events appear here when you interact with the preview.
Bottom sheet: opens halfway, grows when pulled up by the handle (mouse or finger)
A panel that stays open: modal={false}, dismissible={false}
Import
Panel that slides in from an edge of the screen: mobile navigation menu, filters, cart, detail panel, bottom sheet, result list over a map. Has the same props as Dialog (title, icon, onConfirm, footer…); additionally snap points (snapPoints) and non-modal use (modal={false}).
- Dragging: The panel is dragged from anywhere with a finger, from its handle with a mouse. Pushed toward the edge it opens from, it closes (right panels to the right, bottom panels down); a fast flick closes too.
- Snap points: With
snapPoints={[0.4, 0.92]}40% of the screen opens first; pulling grows it, pushing back shrinks or closes it. A fast flick jumps to the next point. Clicking the handle, or focusing it and pressing ↑/↓ (←/→ on side panels), Home/End moves between points. - Content scrolling: While the list isn't at the top, dragging scrolls the list; at the top it shrinks the panel. At the largest point, movement in the growing direction scrolls the list too. Movements perpendicular to the drag direction (like a horizontal gallery) don't move the panel.
- Edge: The edge it opens from always stays attached to the screen. When pulled past the largest point the panel doesn't detach but stretches attached to that edge; when the bottom panel sits above the keyboard, the area behind the keyboard doesn't look empty.
- Esc, the back button and (when modal) clicking the backdrop close it; opening and closing are animated with CSS. It respects safe area insets of notched screens and the on-screen keyboard.
Examples
SheetSide
typeEdge the panel opens from. In right-to-left languages too, left/right are the physical edges.
SheetSnapPoint
typeSnap point: a number between 0–1 is that fraction of the screen (0.5 = half), text like "320px" is a fixed size.
SheetProps
interfaceProps of the Sheet component.
| Name | Type | Default | Description |
|---|---|---|---|
side? | SheetSide | "right" | Edge the panel opens from. |
snapPoints? | readonly SheetSnapPoint[] | Sizes the panel can stop at when dragged with a finger (or the handle with a mouse), from small to large (e.g. [0.4, 0.92]: first 40% of the screen, nearly all of it when pulled up). If omitted, the panel opens to its content size (3/4 of the screen on the sides, at most max-w-sm) and is dragged only to close. | |
snap? | number | Index of the active snap point in controlled use. | |
defaultSnap? | number | 0 | Index of the point to stop at on open in uncontrolled use. |
onSnapChange? | (index: number) => void | Called with the new index when the active snap point changes. | |
modal? | boolean | true | If false the backdrop isn't dimmed and stays interactive (like a list over a map). Focus isn't trapped in the panel. |
dismissible? | boolean | true | If false pulling below the smallest point doesn't close it; the panel always stays open (a persistent bottom panel with modal={false}). |
handle? | boolean | true | Whether to show the drag handle. The handle can be dragged with a mouse too; with several snap points, clicking it and ↑/↓ keys move between points. Not shown while swipeToClose={false}. |
effect? | EffectProp | Effect or effects of the panel surface (e.g. "beam", "glow"). If omitted, UIProvider appearance.defaults.sheet.effect. See BuiltinEffect. | |
open? | boolean | Whether it is open when controlled. | |
defaultOpen? | boolean | false | Is it initially open when uncontrolled? |
onOpenChange? | (open: boolean) => void | Called with the new state when it opens or closes. | |
trigger? | ReactElement | Element that opens the window, usually a Button. The window opens on click; aria-expanded and aria-controls are added automatically. | |
title | ReactNode | Title. Screen readers announce the window with this name, so it is required. To hide it, use classNames={{ title: "sr-only" }}. | |
description? | ReactNode | Description under the title; screen readers read it when the window opens. | |
icon? | IconProp | Icon next to the title: a name or an element. | |
children? | ModalSlot | Body. If a function is given it receives { close, pending }; for example to close the window when a link is clicked. | |
onConfirm? | (data: FormData) => unknown | Called when the confirm button is pressed. The body works like a form: the values of its fields arrive as FormData, and it is not called until browser validation (required etc.) passes. - If it returns a Promise, the confirm button shows loading until it settles and the window does not close (Esc, backdrop and back button wait too). - If it returns false or throws, the window stays open. - Otherwise the window closes. | |
confirmLabel? | ReactNode | Text of the confirm button. If onConfirm is given but this isn't, the UIProvider text ("Onayla") is used. | |
cancelLabel? | ReactNode | {@link UIProvider} text ("İptal") | Text of the cancel button. With null the button is not shown. |
tone? | Tone | "primary" | Color of the confirm button. "danger" for irreversible actions such as deleting. |
footer? | ModalSlot | Footer shown instead of the ready-made buttons. If a function is given it receives { close, pending }. With null no footer is drawn at all. | |
showCloseButton? | boolean | true | Show a close (×) button in the top right corner? |
closeOnBackdropClick? | boolean | true | Close on backdrop click? Pass false for forms where you don't want the user to lose data by accident. |
closeOnBackButton? | boolean | true | Should the browser or phone back button close the window? |
swipeToClose? | boolean | true | Swipe to close with a finger. |
stickyHeader? | boolean | true | Should the header (title, description, icon) stay fixed? When true, only the body scrolls with long content and the header is always visible. When false, the header scrolls with the body. |
stickyFooter? | boolean | true | Should the footer (buttons) stay fixed? When true, the buttons are always visible with long content and the body scrolls above them. When false, the footer is at the end of the content and scrolls with the body. |
className? | string | Classes added to the window itself. | |
classNames? | ModalClassNames | Classes added to the inner parts. |