Convert Figma logo to code with AI

gorhom logoreact-native-bottom-sheet

A performant interactive bottom sheet with fully configurable options 🚀

7,839
843
7,839
68

Top Related Projects

An enhanced, animated, customizable Modal for React Native.

Material Design for React Native (Android & iOS)

UI Components Library for React Native

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.

Quick Overview

The gorhom/react-native-bottom-sheet is a highly customizable and feature-rich bottom sheet component for React Native. It provides a smooth and interactive bottom sheet experience with a variety of built-in features and customization options.

Pros

  • Highly Customizable: The library offers a wide range of customization options, allowing developers to tailor the bottom sheet to their specific needs.
  • Smooth Animation: The bottom sheet transitions and animations are smooth and responsive, providing a seamless user experience.
  • Gesture Support: The library supports various gestures, such as dragging, swiping, and tapping, making the bottom sheet interaction intuitive and natural.
  • Accessibility Features: The library includes accessibility features, ensuring that the bottom sheet is accessible to users with disabilities.

Cons

  • Learning Curve: The library has a relatively steep learning curve, especially for developers who are new to React Native or bottom sheet components.
  • Performance Concerns: Depending on the complexity of the bottom sheet content, the library may have some performance implications, especially on older or less powerful devices.
  • Limited Native Support: The library is a third-party component, and its integration with the native platform may not be as seamless as a built-in solution.
  • Dependency on React Native: The library is tightly coupled with React Native, which means that it may not be suitable for non-React Native projects.

Code Examples

Basic Bottom Sheet

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

const App = () => {
  const bottomSheetRef = React.useRef<BottomSheet>(null);

  const handleSheetChanges = (index: number) => {
    console.log('handleSheetChanges', index);
  };

  return (
    <View style={{ flex: 1 }}>
      <BottomSheet
        ref={bottomSheetRef}
        snapPoints={['25%', '50%', '75%']}
        onChange={handleSheetChanges}
      >
        <View style={{ padding: 24 }}>
          <Text>Awesome Bottom Sheet</Text>
        </View>
      </BottomSheet>
      <Button
        title="Open Bottom Sheet"
        onPress={() => bottomSheetRef.current?.expand()}
      />
    </View>
  );
};

export default App;

This code example demonstrates the basic usage of the BottomSheet component, including setting up the snap points and handling sheet changes.

Customizing the Bottom Sheet

import React from 'react';
import { View, Text, StyleSheet } from 'react-native';
import BottomSheet, { BottomSheetView } from '@gorhom/bottom-sheet';

const App = () => {
  const bottomSheetRef = React.useRef<BottomSheet>(null);

  return (
    <View style={styles.container}>
      <BottomSheet
        ref={bottomSheetRef}
        snapPoints={['25%', '50%', '75%']}
        handleIndicatorStyle={styles.handleIndicator}
        backgroundStyle={styles.background}
        containerStyle={styles.container}
      >
        <BottomSheetView style={styles.contentContainer}>
          <Text style={styles.title}>Customized Bottom Sheet</Text>
          <Text style={styles.content}>
            This bottom sheet has been customized with various styles.
          </Text>
        </BottomSheetView>
      </BottomSheet>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#f2f2f2',
  },
  handleIndicator: {
    backgroundColor: '#333',
  },
  background: {
    backgroundColor: '#fff',
  },
  contentContainer: {
    padding: 24,
  },
  title: {
    fontSize: 18,
    fontWeight: 'bold',
    marginBottom: 8,
  },
  content: {
    fontSize: 16,

Competitor Comparisons

An enhanced, animated, customizable Modal for React Native.

Pros of react-native-modal

  • More versatile, supporting various modal types beyond bottom sheets
  • Simpler API with fewer configuration options, making it easier to use for basic modal needs
  • Lighter weight and potentially better performance for simple modal use cases

Cons of react-native-modal

  • Less specialized for bottom sheet functionality, lacking advanced bottom sheet features
  • Limited customization options compared to react-native-bottom-sheet
  • May require additional work to achieve complex bottom sheet behaviors

Code Comparison

react-native-modal:

<Modal isVisible={isModalVisible} onBackdropPress={() => setModalVisible(false)}>
  <View style={styles.modalContent}>
    <Text>Modal Content</Text>
  </View>
</Modal>

react-native-bottom-sheet:

<BottomSheet
  ref={bottomSheetRef}
  index={1}
  snapPoints={['25%', '50%', '75%']}
>
  <View style={styles.contentContainer}>
    <Text>Bottom Sheet Content</Text>
  </View>
</BottomSheet>

react-native-modal offers a straightforward approach for general modal needs, while react-native-bottom-sheet provides more specialized bottom sheet functionality with advanced features and customization options. The choice between the two depends on the specific requirements of your project, with react-native-modal being suitable for simpler modal use cases and react-native-bottom-sheet excelling in complex bottom sheet implementations.

Material Design for React Native (Android & iOS)

Pros of React Native Paper

  • Comprehensive UI component library with a wide range of pre-built components
  • Follows Material Design guidelines, ensuring a consistent and modern look
  • Extensive documentation and active community support

Cons of React Native Paper

  • May have a larger bundle size due to the extensive component library
  • Less focused on specific functionality like bottom sheets
  • Customization might require more effort for non-Material Design styles

Code Comparison

React Native Paper (Button component):

import { Button } from 'react-native-paper';

<Button mode="contained" onPress={() => console.log('Pressed')}>
  Press me
</Button>

React Native Bottom Sheet (basic usage):

import BottomSheet from '@gorhom/bottom-sheet';

<BottomSheet
  ref={bottomSheetRef}
  snapPoints={['25%', '50%', '75%']}
>
  {/* Bottom sheet content */}
</BottomSheet>

While React Native Paper provides a comprehensive UI toolkit, React Native Bottom Sheet focuses specifically on creating highly customizable bottom sheet components. React Native Paper is better suited for projects requiring a full Material Design implementation, while React Native Bottom Sheet offers more flexibility and performance optimizations for bottom sheet interactions. The choice between the two depends on the specific needs of your project and the desired level of customization for bottom sheet functionality.

UI Components Library for React Native

Pros of react-native-ui-lib

  • Comprehensive UI component library with a wide range of pre-built components
  • Consistent design system and theming capabilities
  • Includes additional utilities and helpers for React Native development

Cons of react-native-ui-lib

  • Larger package size due to the extensive component library
  • Steeper learning curve for developers unfamiliar with the library's conventions
  • May require more customization for specific design requirements

Code Comparison

react-native-ui-lib:

import { View, Text, Button } from 'react-native-ui-lib';

const MyComponent = () => (
  <View>
    <Text>Hello World</Text>
    <Button label="Click me" onPress={() => {}} />
  </View>
);

react-native-bottom-sheet:

import BottomSheet from '@gorhom/bottom-sheet';

const MyComponent = () => (
  <BottomSheet
    snapPoints={['25%', '50%', '75%']}
    onChange={handleSheetChanges}
  >
    <View>
      <Text>Bottom Sheet Content</Text>
    </View>
  </BottomSheet>
);

While react-native-ui-lib offers a comprehensive set of UI components, react-native-bottom-sheet focuses specifically on providing a highly customizable bottom sheet component. The choice between the two depends on the project's specific needs and the desired level of control over the bottom sheet functionality.

Mobile-first, accessible components for React Native & Web to build consistent UI across Android, iOS and Web.

Pros of NativeBase

  • Comprehensive UI component library with a wide range of pre-built components
  • Customizable theme system for consistent styling across the app
  • Cross-platform compatibility with web support

Cons of NativeBase

  • Larger bundle size due to the extensive component library
  • Steeper learning curve for developers new to the framework
  • Less focused on specific functionality compared to React Native Bottom Sheet

Code Comparison

NativeBase example:

import { Box, Text, VStack } from 'native-base';

const Example = () => (
  <Box>
    <VStack space={4}>
      <Text>Hello World</Text>
    </VStack>
  </Box>
);

React Native Bottom Sheet example:

import BottomSheet from '@gorhom/bottom-sheet';

const Example = () => (
  <BottomSheet
    snapPoints={['25%', '50%', '75%']}
    index={1}
  >
    <View>
      <Text>Hello World</Text>
    </View>
  </BottomSheet>
);

While NativeBase provides a comprehensive set of UI components and theming capabilities, React Native Bottom Sheet focuses specifically on implementing a highly customizable bottom sheet component. NativeBase offers a broader range of components and styling options, making it suitable for building entire app interfaces. React Native Bottom Sheet, on the other hand, excels in providing a polished and feature-rich bottom sheet implementation for specific use cases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

React Native Bottom Sheet

Reanimated v3 version Reanimated v2 version Reanimated v1 version
license npm runs with expo
NPM Downloads

A performant interactive bottom sheet with fully configurable options 🚀

React Native Bottom Sheet


Features

  • ⭐️ Support React Native Web, read more.
  • ⭐️ Dynamic Sizing, read more.
  • ⭐️ Support FlashList, read more.
  • Modal presentation view, Bottom Sheet Modal.
  • Smooth gesture interactions & snapping animations.
  • Seamless keyboard handling for iOS & Android.
  • Support pull to refresh for scrollables.
  • Support FlatList, SectionList, ScrollView & View scrolling interactions, read more.
  • Support React Navigation Integration, read more.
  • Compatible with Reanimated v1-3.
  • Compatible with Expo.
  • Accessibility support.
  • Written in TypeScript.
  • Read more.

Getting Started

Check out the documentation website.

Versioning

This library been written in 3 versions of Reanimated, and kept all implementation in separate branches:

  • v5 | branch | changelog : written with Reanimated v3 & Gesture Handler v2.

  • v4 (not maintained) | branch | changelog : written with Reanimated v2.

  • v2 (not maintained) | branch | changelog : written with Reanimated v1 & compatible with Reanimated v2.

I highly recommend to use v5 which provides more stability with all latest features.

Author

Sponsor & Support

To keep this library maintained and up-to-date please consider sponsoring it on GitHub. Or if you are looking for a private support or help in customizing the experience, then reach out to me on Twitter @gorhom.

License

MIT


Mo Gorhom Mo Gorhom