Command palette

@yasinsensoy/native

React Native · Components

Sheet

A panel that slides in from a screen edge: side menu, filters, cart, bottom sheet, result list over a map.

5 exports

Live example

The preview runs in the browser with the web component; the native component takes the same props and looks the same on iOS and Android.

Preview

Menu

You can close it by pushing it towards the edge.

Code

import { Sheet, Button } from "@yasinsensoy/native";

<Sheet
  trigger={<Button variant="outline">Open sheet</Button>}
  title="Menu"
  description="You can close it by pushing it towards the edge."
>
  {({ close }) => <nav onClick={close}>…</nav>}
</Sheet>

Events

  1. Events appear here when you interact with the preview.

Bottom sheet: opens halfway, grows when pulled up by the handle (mouse or finger)

Nearby stores

Pull up to grow, pull down to shrink or close.

  • Store 10.3 km
  • Store 20.7 km
  • Store 31.1 km
  • Store 41.5 km
  • Store 51.9 km
  • Store 62.3 km
  • Store 72.7 km
  • Store 83.1 km
  • Store 93.5 km
  • Store 103.9 km
  • Store 114.3 km
  • Store 124.7 km
  • Store 135.1 km
  • Store 145.5 km
  • Store 155.9 km
  • Store 166.3 km
  • Store 176.7 km
  • Store 187.1 km
  • Store 197.5 km
  • Store 207.9 km
  • Store 218.3 km
  • Store 228.7 km
  • Store 239.1 km
  • Store 249.5 km
  • Store 259.9 km
  • Store 2610.3 km
  • Store 2710.7 km
  • Store 2811.1 km
  • Store 2911.5 km
  • Store 3011.9 km

A panel that stays open: modal={false}, dismissible={false}

Results

  • Store 10.3 km
  • Store 20.7 km
  • Store 31.1 km
  • Store 41.5 km
  • Store 51.9 km
  • Store 62.3 km
  • Store 72.7 km
  • Store 83.1 km
  • Store 93.5 km
  • Store 103.9 km
  • Store 114.3 km
  • Store 124.7 km
  • Store 135.1 km
  • Store 145.5 km
  • Store 155.9 km
  • Store 166.3 km
  • Store 176.7 km
  • Store 187.1 km
  • Store 197.5 km
  • Store 207.9 km
  • Store 218.3 km
  • Store 228.7 km
  • Store 239.1 km
  • Store 249.5 km
  • Store 259.9 km
  • Store 2610.3 km
  • Store 2710.7 km
  • Store 2811.1 km
  • Store 2911.5 km
  • Store 3011.9 km

Import

import { Sheet, useSheetScroll } from "@yasinsensoy/native";

Sheet

component

A panel that slides in from a screen edge: side menu, filters, cart, bottom sheet, result list over a map. Same API as the web Sheet; in addition to all of Dialog's props there are snap points (snapPoints) and non-modal use.

  • Dragging: The panel can be dragged by any part with a finger; pushing it towards its edge or a quick fling closes it. With snap points a fling jumps to the next point.
  • Content scrolling: When the body is at the top, pulling down shrinks the panel; content does not scroll until the panel reaches its largest point (the panel grows first). For your own list use useSheetScroll.
  • Edge: The edge it opens from always stays attached to the screen. Pulling beyond the largest point does not detach the panel from the edge; it stretches attached to that edge. When a bottom panel sits on the keyboard, no gap shows behind the keyboard's rounded corners.
  • The Android back button and (when modal) tapping the backdrop close it. Respects safe area insets and the on-screen keyboard. Looks the same on iOS and Android; animations run on the native driver.
Sheet({ side, snapPoints, snap, defaultSnap, onSnapChange, modal, dismissible, handle, trigger, open, defaultOpen, onOpenChange, onConfirm, closeOnBackdropClick, closeOnBackButton, swipeToClose, style, testID, ...layout }: SheetProps): JSX.Element

Examples

<Sheet side="left" title="Menu" trigger={<Button icon="menu" variant="ghost" />}>
  {({ close }) => <Menu onNavigate={close} />}
</Sheet>

// Half-open bottom sheet that grows when pulled up
<Sheet side="bottom" title="Nearby stores" snapPoints={[0.35, 0.9]}
  trigger={<Button>Open list</Button>}>
  <StoreList />
</Sheet>

// A panel that always stays open over a map
<Sheet side="bottom" title="Results" open modal={false} dismissible={false}
  snapPoints={["120px", 0.5, 0.9]} showCloseButton={false}>…</Sheet>

If you put your own ScrollView/FlatList inside a Sheet or Dialog, pass these props: pulling down while the list is at the top shrinks the panel, and the list does not scroll until the panel reaches its largest point. Returns null outside a window.

useSheetScroll(): SheetScrollProps | null

Examples

const scroll = useSheetScroll();
<FlatList data={data} renderItem={…} {...scroll} />

SheetProps

interface

Props of the Sheet component (same as web).

Extends: ModalOwnProps

NameTypeDefaultDescription
side?SheetSide"right"Edge the panel opens from.
snapPoints?readonly SheetSnapPoint[]Sizes the panel can rest at while dragging, smallest to largest (e.g. [0.4, 0.92]: first 40% of the screen, almost 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 384 pixels) and is dragged only to close.
snap?numberIndex of the active snap point in controlled use.
defaultSnap?number0Index of the point to rest at when opened, in uncontrolled use.
onSnapChange?(index: number) => voidCalled with the new index when the active snap point changes.
modal?booleantrueWhen false the backdrop is not dimmed and stays interactive (like a list over a map).
dismissible?booleantrueWhen false pulling below the smallest point does not close it; the panel always stays open (a persistent bottom panel with modal={false}).
handle?booleantrueShow the drag handle? Tapping the handle cycles between points; for screen readers it is an adjustable element (swipe up/down). Not shown when swipeToClose={false}.

Snap point: a number between 0 and 1 is that fraction of the screen (0.5 = half), text like "320px" is a fixed size.

type SheetSnapPoint = number | `${number}px`

Edge the panel opens from. In right-to-left languages too, left/right are physical edges.

type SheetSide = "top" | "right" | "bottom" | "left"