Scroll Bottom Sheet
Cross platform scrollable bottom sheet with virtualisation support, with animations and gestures running at 60 FPS and fully implemented in JS land. It supports all core scrollable components from React Native: FlatList, ScrollView and SectionList :rocket:
Installation
npm
npm i react-native-scroll-bottom-sheet
yarn
yarn add react-native-scroll-bottom-sheet
Usage
The below is an example using the core FlatList
from React Native as the scrollable component.
import React from 'react';
import { Dimensions, StyleSheet, Text, View } from 'react-native';
import ScrollBottomSheet from 'react-native-scroll-bottom-sheet';
function Example() {
const windowHeight = Dimensions.get('window').height;
return (
<View style={styles.container}>
<ScrollBottomSheet
componentType="FlatList"
snapPoints={[128, '50%', windowHeight - 200]}
initialSnapIndex={2}
renderHandle={() => (
<View style={styles.header}>
<View style={styles.panelHandle} />
</View>
)}
data={Array.from({ length: 200 }).map((_, i) => String(i))}
keyExtractor={i => i}
renderItem={({ item }) => (
<View style={styles.item}>
<Text>{`Item ${item}`}</Text>
</View>
)}
contentContainerStyle={styles.contentContainerStyle}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
contentContainerStyle: {
padding: 16,
backgroundColor: '#F3F4F9',
},
header: {
alignItems: 'center',
backgroundColor: 'white',
paddingTop: 20,
borderTopLeftRadius: 20,
borderTopRightRadius: 20,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: -10,
},
shadowOpacity: 0.1,
shadowRadius: 5.0,
elevation: 16,
},
panelHandle: {
width: 40,
height: 2,
backgroundColor: 'rgba(0,0,0,0.3)',
borderRadius: 4,
marginBottom: 10,
},
item: {
padding: 20,
justifyContent: 'center',
backgroundColor: 'white',
alignItems: 'center',
marginVertical: 10,
},
});
License
MIT