MCPcopy Index your code
hub / github.com/Temzasse/react-modal-sheet

github.com/Temzasse/react-modal-sheet @v5.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v5.6.0 ↗ · + Follow
127 symbols 366 edges 67 files 1 documented · 1%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

React Modal Sheet logo

· Flexible bottom sheet component for your React apps ·

npm version npm license npm downloads

📦 Installation

npm install react-modal-sheet

Peer dependencies

The gestures and animations are handled by the excellent Motion library so before you can start using this library you need to install motion:

npm install motion

📚 Table of contents


💻 Usage

import { Sheet } from 'react-modal-sheet';
import { useState } from 'react';

function Example() {
  const [isOpen, setOpen] = useState(false);

  return (
    <>
      <button onClick={() => setOpen(true)}>Open sheet</button>

      <Sheet isOpen={isOpen} onClose={() => setOpen(false)}>
        <Sheet.Container>
          <Sheet.Header />
          <Sheet.Content>{/* Your sheet content goes here */}</Sheet.Content>
        </Sheet.Container>
        <Sheet.Backdrop />
      </Sheet>
    </>
  );
}

The Sheet component follows the Compound Component pattern in order to provide a flexible yet powerful API for creating highly customizable bottom sheet components.

Since the final bottom sheet is composed from smaller building blocks (Container, Content, Header, and Backdrop) you are in total control over the rendering output. So for example, if you don't want to have any backdrop in your sheet then you can just skip rendering it instead of passing some prop like renderBackdrop={false} to the main sheet component. Cool huh? 😎

Also, by constructing the sheet from smaller pieces makes it easier to apply any necessary accessibility related properties to the right components without requiring the main sheet component to be aware of them. You can read more about accessibility in the Accessibility section below.

🎛️ Props

Name Required Default Description
children yes Use Sheet.Container/Content/Header/Backdrop to compose your bottom sheet.
isOpen yes Boolean that indicates whether the sheet is open or not.
onClose yes Callback fn that is called when the sheet is closed by the user.
avoidKeyboard no true Automatically avoid the virtual keyboard by adding bottom padding when the keyboard is open. Only works on mobile devices with Virtual Keyboard or Visual Viewport API support.
disableDrag no false Disable drag for the whole sheet.
disableDismiss no false Disable dismissing the sheet via dragging or high velocity swipe. When enabled, the sheet can only be closed programmatically.
disableScrollLocking no false Disable scroll locking for the body element while sheet is open. Can be useful if you face issues with input elements and the iOS virtual keyboard. See related issue.
detent no 'default' The detent in which the sheet should be in when opened. Available values: 'default', 'content', or 'full'.
onOpenStart no Callback fn that is called when the sheet opening animation starts.
onOpenEnd no Callback fn that is called when the sheet opening animation is completed.
onCloseStart no Callback fn that is called when the sheet closing animation starts.
onCloseEnd no Callback fn that is called when the sheet closing animation is completed.
onSnap no Callback fn that is called with the current snap point index when the sheet snaps to a new snap point. Requires snapPoints prop.
snapPoints no Eg. [0, 0.5, 100, 1] - where positive values are pixels from the bottom of the sheet and negative from the top. Values between 0-1 represent percentages, eg. 0.5 means 50% of sheet height. Must be in ascending order and should include 0 (closed) and 1 (fully open).
initialSnap no 0 Initial snap point when sheet is opened (index from snapPoints).
modalEffectRootId no The id of the element where the main app is mounted, eg. "root". Enables iOS modal effect.
modalEffectThreshold no 0 Threshold value between 0-1 which determines when the iOS modal effect will start while dragging the sheet - 0 corresponding to the start of the drag (0% has been dragged into view) and 1 corresponding to the end of the drag (100% of the sheet is visible).
tweenConfig no { ease: 'easeOut', duration: 0.2 } Overrides the config for the sheet tween transition when the sheet is opened, closed, or snapped to a point.
mountPoint no document.body HTML element that should be used as the mount point for the sheet.
prefersReducedMotion no false Skip sheet animations (sheet instantly snaps to desired location).
dragVelocityThreshold no 500 How fast the sheet must be flicked down to close. Higher values make the sheet harder to close.
dragCloseThreshold no 0.6 The portion of the sheet which must be dragged off-screen before it will close.
unstyled no false Remove all decorative styles and only apply base functional styles. Useful when you want to completely customize the sheet appearance.

⚙️ Methods and properties

React Modal Sheet exposes several methods and properties that can be accessed via a ref or the sheet context.

These allow you to imperatively control the sheet's behavior and access its internal state.

Name Type Description
y MotionValue<number> Current sheet Y position where 0 means fully open at the top.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Function 117
Interface 10

Languages

TypeScript100%

Modules by API surface

src/hooks/use-prevent-scroll.ts15 symbols
src/utils.ts10 symbols
src/hooks/use-virtual-keyboard.ts9 symbols
src/snap.ts8 symbols
src/types.tsx6 symbols
example/src/components/apple-maps/index.tsx6 symbols
src/hooks/use-modal-effect.ts4 symbols
example-ssr/src/components/sheet-example.tsx4 symbols
example/src/components/slack-message/index.tsx3 symbols
example/src/components/scrollable-snap-points.tsx3 symbols
example/src/components/disable-drag.tsx3 symbols
example/src/components/apple-music/index.tsx3 symbols

For agents

$ claude mcp add react-modal-sheet \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page