@devvie/bottom-sheet

中文文档
0.5.0发布于 2026/07/05MITTypeScriptESM + CJS零依赖近 30 天下载 5.9万

The 😎smart , 📦tiny , and 🎗flexible bottom sheet your app craves 🚀

原始使用文档
文档目录17 节
  1. 💻 Installation
  2. 🤔 Why this bottom sheet?
  3. 📱 Basic Example
  4. ⚠ Warning
  5. 🛠 Props
  6. Ref methods
  7. Examples
  8. 1️⃣ Smart response to keyboard pop ups and orientation chan…
  9. 2️⃣ Handles deeply nested list and scroll views interaction…
  10. 3️⃣ Auto adjusts layout when height and containerHeight pro…
  11. 4️⃣ Extend sheet height when its content is scrolled
  12. 5️⃣ Use as SnackBar
  13. 6️⃣ Custom Drag Handle Animation Interpolation
  14. 7️⃣ Custom Scrim/Backdrop Mask
  15. Contributing
  16. License
  17. Support

React Native Bottom Sheet 💖

GitHub GitHub Workflow Status (with event) runs with expo GitHub code size in bytes npm bundle size (scoped) npm downloads

The smart 😎, tiny 📦, and flexible 🎗 bottom sheet your app craves 🚀


👉🏾 Buy Me A Coffee 👈🏾


Android & iOS Preview

Preview for Android & iOS

Web Preview

Preview for Web

💻 Installation

npm install @devvie/bottom-sheet
# or
yarn add @devvie/bottom-sheet

🤔 Why this bottom sheet?

🚀 Plug and play — npm install and you're done. Zero third-party dependencies, no Babel plugins, no pod install. Built entirely on React Native's own APIs.

⌨️ Keyboard intelligence — The sheet auto-detects the keyboard mode (adjustPan / adjustResize), measures its own live position on screen, and animates to a safe height when a text input is focused — all without any configuration or wrapper components.

📦 Tiny footprint — ~4 KB minzipped. Extremely lightweight and fast, leaving virtually no impact on your bundle size.

🎯 Snap points — Define resting positions with a mix of % and px values. Snap points are automatically sorted in ascending order internally, meaning index 0 always represents the smallest/collapsed position. The sheet snaps to the nearest point on release with velocity-aware physics, and exposes snapToIndex, expand, and collapse for full programmatic control.

📟 Live prop updates — Dynamically change height, snapPoints, or containerHeight at any time and the sheet re-syncs its layout, clamps its active index, and fires callbacks automatically.

🌐 Truly cross-platform — iOS, Android, Web, and Expo, all from pure React Native primitives. No native modules required.

🎞 3 animation types — Choose between slide, spring, and fade out of the box, or supply your own custom easing function. Animation durations are fully configurable for both open and close transitions.

📜 Nested scrolling — Works with FlatList, SectionList, and ScrollView inside the sheet. Drag the handle to move the sheet; scroll the list to scroll its content — no gesture conflicts.

🎨 Custom components — Swap the drag handle or backdrop with your own animated components. Both receive the sheet's animated height value for interpolation, so you can build rich interactive handles and scrims.

✨ Modal & non-modal — Use as a full modal with backdrop mask, or as a lightweight inline sheet with elevation shadow. Supports custom backdrop components positioned above or behind the sheet.

✅ TypeScript-first — Fully typed props with compile-time safety. height and snapPoints are enforced as mutually exclusive at the type level.

📱 Basic Example

Opening and closing the bottom sheet is done imperatively. Pass a ref to the bottom sheet and call the open() or close() methods.

1. Single height (default)

import React, { useRef } from 'react';
import BottomSheet, { BottomSheetMethods } from '@devvie/bottom-sheet';
import { Button, Text, View } from 'react-native';

const App = () => {
  const sheetRef = useRef<BottomSheetMethods>(null);
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Button title="Open Sheet" onPress={() => sheetRef.current?.open()} />
      <BottomSheet ref={sheetRef} height={300}>
        <Text>
          The smart 😎, tiny 📦, and flexible 🎗 bottom sheet your app craves 🚀
        </Text>
      </BottomSheet>
    </View>
  );
};

export default App;

2. With snap points (multi-height)

import React, { useRef } from 'react';
import BottomSheet, { BottomSheetMethods } from '@devvie/bottom-sheet';
import { Button, Text, View } from 'react-native';

const App = () => {
  const sheetRef = useRef<BottomSheetMethods>(null);
  return (
    <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
      <Button title="Open Sheet" onPress={() => sheetRef.current?.open()} />
      <BottomSheet
        ref={sheetRef}
        snapPoints={['30%', 450, '90%']}
        index={0}
        onSnap={(index) => console.log('snapped to', index)} // index 0..2, or -1 on close
      >
        <Text>Drag me between snap points 🎯</Text>
      </BottomSheet>
    </View>
  );
};

export default App;

⚠ Warning

The bottom sheet component uses and handles pan gestures internally, so to avoid scroll/pan misbehavior with its container, DO NOT put it inside a container that supports panning e.g ScrollView. You can always put it just next to the ScrollView and use React Fragment or a View to wrap them and everything should be okay.

❌ Don't do this

<ScrollView>
  <BottomSheet>...</BottomSheet>
</ScrollView>

✅ Do this

<>
  <ScrollView>...</ScrollView>

  <BottomSheet>...</BottomSheet>
</>

🛠 Props

The bottom sheet is highly configurable via props. All props works for both Android and iOS except those prefixed with android_ and ios_, which works for only Android and iOS respectively.

PropertyTypeDefaultDescriptionRequired
android_backdropMaskRippleColorstring | OpaqueColorValueColor of the ripple effect when backdrop mask is pressed (Android Only).No
android_closeOnBackPressbooleantrueDetermines whether the sheet will close when the device back button is pressed (Android Only).No
animationType'slide' | 'spring' | 'fade' | ANIMATIONS'slide'Animation to use when opening and closing the bottom sheet.No
backdropMaskColorstring | OpaqueColorValue'#00000052'Color of the scrim or backdrop mask.No
childrenViewProps['children'] | React.FunctionComponent<{_animatedHeight: Animated.Value}>nullContents of the bottom sheet.Yes
closeDurationnumber500Duration for sheet closing animation.No
closeOnBackdropPressbooleantrueDetermines whether the bottom sheet will close when the scrim or backdrop mask is pressed.No
closeOnDragDownbooleantrueDetermines whether the bottom sheet will close when dragged down.No
containerHeightViewStyle['height']DEVICE SCREEN HEIGHTHeight of the bottom sheet's overall container.No
customBackdropComponentReact.FunctionComponent<{_animatedHeight: Animated.Value}>nullCustom component for sheet's scrim or backdrop mask.No
customBackdropPosition"top" | "behind"'behind'Determines the position of the custom scrim or backdrop component. 'behind' puts it behind the keyboard and `'top'`` puts it atop the keyboard.No
customDragHandleComponentReact.FC<{_animatedHeight: Animated.Value}>Custom drag handle component to replace the default bottom sheet's drag handle.No
customEasingFunctionAnimationEasingFunctionANIMATIONS.SLIDECustom easing function for driving sheet's animation.No
disableBodyPanningbooleanfalsePrevents the bottom sheet from being dragged/panned down on its body.No
disableDragHandlePanningbooleanfalsePrevents the bottom sheet from being panned down by dragging its drag handle.No
dragHandleStyleViewStyleExtra styles to apply to the drag handle.No
heightnumber | string'50%'Height of the bottom sheet when opened. Relative to containerHeight propNo
hideDragHandlebooleanfalseWhen true, hides the sheet's drag handle.No
indexnumber0Snap point index the sheet opens to (when snapPoints is set). 0 is the smallest point. Initial position only (not reactive).No
modalbooleantrueDetermines whether the sheet is a modal. A modal sheet has a scrim or backdrop mask, while a standard (non-modal) sheet doesn't.No
onSnap(index: number) => voidCalled when the sheet settles on a snap point (drag or programmatic); -1 on close.No
openDurationnumber500Duration for sheet opening animation.No
snapPoints(number | string)[]undefinedResting positions, a mix of px numbers and '%' strings e.g. ['30%', 600]. Takes precedence over height. Snap via drag or ref methods.No
styleOmit<ViewStyle, 'height' | 'minHeight' | 'maxHeight' | 'transform:[{translateY}]'>Extra styles to apply to the bottom sheet.No

Ref methods

The sheet's ref exposes the following methods:

MethodDescription
open()Open the bottom sheet (to the index prop if snapPoints is provided, otherwise height).
close()Close the bottom sheet.
snapToIndex(index)Animate to the snap point at index (clamped). -1 closes; opens the sheet if it is closed.
expand()Animate to the largest snap point.
collapse()Animate to the smallest snap point.
sheetRef.current?.open(); // open sheet
sheetRef.current?.close(); // close sheet
sheetRef.current?.snapToIndex(2); // jump to the 3rd (largest) point
sheetRef.current?.expand(); // largest point
sheetRef.current?.collapse(); // smallest point

When snapPoints is not provided these methods resolve to the single height, so they're always safe to call.

Examples

Flexibility is a focus for this bottom sheet, these few examples shows certain behaviors of the bottom sheet and what can be achieved by tweaking its props.

1️⃣ Smart response to keyboard pop ups and orientation changes (default behavior)

AndroidiOS
Preview for keyboard handling (Android)Preview for keyboard handling (iOS)

2️⃣ Handles deeply nested list and scroll views interactions (default behavior)

AndroidiOS
Preview for scroll handling (Android)Preview for scroll handling (iOS)

3️⃣ Auto adjusts layout when height and containerHeight props change (default behavior)

4️⃣ Extend sheet height when its content is scrolled

5️⃣ Use as SnackBar

6️⃣ Custom Drag Handle Animation Interpolation

7️⃣ Custom Scrim/Backdrop Mask

More examples coming soon...

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

see LICENSE


Support

</> with 💖 by Devvie ✌

版本与发布记录

@devvie/bottom-sheet 共发布 11 个版本,首次发布于 2023/10/10;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.5.0latest2026/07/054 个月前
0.4.42026/05/185 个月前
0.4.32024/10/302 年前
0.4.22024/09/142 年前
0.4.12024/09/142 年前
0.4.02024/09/132 年前

关于 @devvie/bottom-sheet 的常见问题

@devvie/bottom-sheet 是什么?

The 😎smart , 📦tiny , and 🎗flexible bottom sheet your app craves 🚀

如何安装 @devvie/bottom-sheet?

在项目目录运行 npm install @devvie/bottom-sheet,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=18.2.0)、react-native(>=0.73.4)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@devvie/bottom-sheet 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@devvie/bottom-sheet 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@devvie/bottom-sheet 可以商用吗?

@devvie/bottom-sheet 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@devvie/bottom-sheet 的下载量有多少?

根据 npm 官方下载统计,@devvie/bottom-sheet 在 2026/10/12 – 2026/11/10 这 30 天内被下载 59,003 次,日均约 1,967 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@devvie/bottom-sheet 还在维护吗?

最新版本 0.5.0 发布于 2026/07/05(4 个月前);至今共发布 11 个版本,其中过去 12 个月发布了 2 个;首次发布于 2023/10/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。