React Native Bottom Sheet
website·Indexed 33 days ago
https://gorhom.dev/react-native-bottom-sheet/A library for creating bottom sheets in React Native, featuring integrated components like BottomSheetFlatList, BottomSheetScrollView, and BottomSheetTextInput. Supports multiple versions including v2 (Reanimated v1), v4 (Reanimated v2), and v5, with specialized functionality for Bottom Sheet Modals and keyboard handling.
What's inside React Native Bottom Sheet
- The Bottom Sheet Modal is a wrapper/decorator built on top of the standard Bottom Sheet. It inherits all standard Bottom Sheet functionalities while adding specialized modal presentation capabilities, including support for stacked sheet modals (inspired by Apple Maps) and smooth mounting animations.
Overview of @gorhom/bottom-sheet features
The
@gorhom/bottom-sheetlibrary provides a performant interactive bottom sheet for React Native with the following capabilities:- Platform Support: Works with React Native Web and is written in TypeScript.
- Sizing & Layout: Supports Dynamic Sizing and Modal presentation views.
- Interactions: Smooth gesture interactions, snapping animations, and accessibility support.
- Scrollable Integration: Supports
FlatList,SectionList,ScrollView,View, andFlashListscrolling interactions, including pull-to-refresh. - System Integration: Seamless keyboard handling for iOS and Android, and integration with
React Navigation. - Compatibility: Compatible with Reanimated v1, v2, and v3.
Overview of Bottom Sheet Modal in react-native-bottom-sheet v4
v4The Bottom Sheet Modal is a wrapper/decorator for the standard Bottom Sheet. It inherits all standard Bottom Sheet functionalities while adding specific modal presentation capabilities, including support for stacked sheet modals (inspired by Apple Maps) and smooth mounting animations.Overview of @gorhom/bottom-sheet v4 features
v4The
@gorhom/bottom-sheetlibrary provides a performant interactive bottom sheet for React Native. Key features include:- Modal presentation via Bottom Sheet Modal.
- Smooth gesture interactions and snapping animations.
- Keyboard handling for both iOS and Android.
- Pull-to-refresh support for scrollable components.
- Integration with
FlatList,SectionList,ScrollView, andViewscrolling. - Integration with
React Navigation. - Compatibility with Reanimated v2 and v3, and Expo.
- Full TypeScript support and accessibility features.
Overview of Bottom Sheet Modal
v2The Bottom Sheet Modal is a wrapper/decorator built on top of the base Bottom Sheet. It inherits all standard Bottom Sheet functionalities while adding specific modal presentation capabilities, such as smooth interaction, mounting animations, and support for stacked sheet modals (inspired by Apple Maps).Use BottomSheetVirtualizedList for scrollable content in BottomSheet
BottomSheetVirtualizedList is a pre-integrated React Native VirtualizedList designed to work with BottomSheet gestures. It inherits all standardVirtualizedListPropsfromreact-native.import { BottomSheetVirtualizedList } from "@gorhom/bottom-sheet"; <BottomSheetVirtualizedList data={data} keyExtractor={(i) => i} getItemCount={(data) => data.length} getItem={(data, index) => data[index]} renderItem={renderItem} />Capabilities of @gorhom/bottom-sheet v2
v2The @gorhom/bottom-sheet v2 library provides a performant interactive bottom sheet with the following features:
- Modal presentation via Bottom Sheet Modal.
- Smooth gesture interactions and snapping animations.
- Scrolling interaction support for
FlatList,SectionList,ScrollView, andView. - Integration with
React Navigation. - Compatibility with
ExpoandReanimated v1. - Full TypeScript support and accessibility features.
Use BottomSheetSectionList for sectioned lists in a BottomSheet
TheBottomSheetSectionListcomponent is a pre-integrated version of the React NativeSectionListdesigned to work withBottomSheetgestures. It inherits all standardSectionListPropsfromreact-native.import BottomSheet, { BottomSheetSectionList } from "@gorhom/bottom-sheet"; // ... inside component <BottomSheet snapPoints={['25%', '50%', '90%']}> <BottomSheetSectionList sections={sections} keyExtractor={(i) => i} renderSectionHeader={renderSectionHeader} renderItem={renderItem} /> </BottomSheet>Use BottomSheetScrollView for scrollable content in BottomSheet
TheBottomSheetScrollViewis a pre-integrated React Native ScrollView designed to work withBottomSheetgestures. It inherits all standardScrollViewPropsfromreact-native.import BottomSheet, { BottomSheetScrollView } from "@gorhom/bottom-sheet"; const MyComponent = () => ( <BottomSheet snapPoints={['25%', '50%', '90%']}> <BottomSheetScrollView contentContainerStyle={{ backgroundColor: 'white' }}> {/* Your scrollable content here */} </BottomSheetScrollView> </BottomSheet> );Use BottomSheetScrollView for scrollable content in a BottomSheet
v4TheBottomSheetScrollViewis a pre-integrated React Native ScrollView designed to work withBottomSheetgestures. It inherits all standardScrollViewPropsfromreact-native.import BottomSheet, { BottomSheetScrollView } from "@gorhom/bottom-sheet"; const App = () => { return ( <BottomSheet snapPoints={["25%", "50%", "90%"]}> <BottomSheetScrollView contentContainerStyle={{ backgroundColor: 'white' }}> {/* Your scrollable content here */} </BottomSheetScrollView> </BottomSheet> ); };Use BottomSheetFlashList for high-performance lists in BottomSheet
The
BottomSheetFlashListis a pre-integrated version of Shopify'sFlashListdesigned to work withBottomSheetgestures. It inherits allFlashListPropsfrom the standard FlashList library.Deprecation Notice: As of v5,
BottomSheetFlashListis deprecated. It is recommended to use theuseBottomSheetScrollableCreatorhook for a simpler approach to integrating scrollable components.import BottomSheet, { BottomSheetFlashList } from "@gorhom/bottom-sheet"; // ... inside component <BottomSheet ref={sheetRef} snapPoints={snapPoints}> <BottomSheetFlashList data={data} keyExtractor={(item) => item} renderItem={renderItem} estimatedItemSize={43.3} /> </BottomSheet>Use BottomSheetTextInput for keyboard-aware inputs
TheBottomSheetTextInputcomponent is a pre-integratedTextInputdesigned to communicate with the internal functionalities of the bottom sheet. This ensures that keyboard handling (such as shifting the sheet up when the keyboard appears) works correctly. It inherits all standardTextInputPropsfromreact-native.import React, { useCallback, useMemo, useRef } from 'react'; import { View, Text, StyleSheet } from 'react-native'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; import BottomSheet, { BottomSheetView, BottomSheetTextInput } from '@gorhom/bottom-sheet'; const App = () => { const bottomSheetRef = useRef<BottomSheet>(null); const snapPoints = useMemo(() => ['25%', '50%'], []); const handleSheetChanges = useCallback((index: number) => { console.log('handleSheetChanges', index); }, []); return ( <GestureHandlerRootView style={styles.container}> <BottomSheet ref={bottomSheetRef} index={1} snapPoints={snapPoints} keyboardBehavior="fillParent" enableDynamicSizing={false} onChange={handleSheetChanges} > <BottomSheetTextInput style={styles.input} /> <BottomSheetView style={styles.contentContainer}> <Text>Awesome 🎉</Text> </BottomSheetView> </BottomSheet> </GestureHandlerRootView> ); }; const styles = StyleSheet.create({ container: { flex: 1, padding: 24, backgroundColor: 'grey' }, contentContainer: { flex: 1, alignItems: 'center' }, input: { marginTop: 8, marginBottom: 10, borderRadius: 10, fontSize: 16, lineHeight: 20, padding: 8, backgroundColor: 'rgba(151, 151, 151, 0.25)', }, }); export default App;