Socket
Socket
Sign inDemoInstall

@nonam4/react-native-bottom-sheet

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @nonam4/react-native-bottom-sheet

Add Whatever You Want To Bottom Sheet (Android & iOS)


Version published
Maintainers
1
Install size
2.42 MB
Created

Readme

Source

react-native-bottom-sheet

npm version npm downloads

  • Super Lightweight Component
  • Add Your own Component To Bottom Sheet
  • Customize Whatever You Like
  • Support Drag Down Gesture
  • Support All Orientations
  • Support Both Android And iOS
  • Smooth Animation
  • Zero Configuration
  • Zero dependency
Showcase iOSShowcase Android

Installation

npm i @nonam4/react-native-bottom-sheet --save

or

yarn add @nonam4/react-native-bottom-sheet

Example

Class component
import React, { Component } from "react";
import { View, Button } from "react-native";
import RBSheet from "@nonam4/react-native-bottom-sheet";

export default class Example extends Component {
  render() {
    return (
      <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
        <Button title="OPEN BOTTOM SHEET" onPress={() => this.RBSheet.open()} />
        <RBSheet
          ref={ref => {
            this.RBSheet = ref;
          }}
          height={300}
          openDuration={250}
          customStyles={{
            container: {
              justifyContent: "center",
              alignItems: "center"
            }
          }}
        >
          <YourOwnComponent />
        </RBSheet>
      </View>
    );
  }
}
Functional component
import React, { useRef } from "react";
import { View, Button } from "react-native";
import RBSheet from "@nonam4/react-native-bottom-sheet";

export default function Example() {
  const refRBSheet = useRef<RBSheet | null>(null);
  return (
    <View
      style={{
        flex: 1,
        justifyContent: "center",
        alignItems: "center",
        backgroundColor: "#000"
      }}
    >
      <Button title="OPEN BOTTOM SHEET" onPress={() => refRBSheet.current?.open()} />
      <RBSheet
        ref={refRBSheet}
        closeOnDragDown={true}
        closeOnPressMask={false}
        customStyles={{
          wrapper: {
            backgroundColor: "transparent"
          },
          draggableIcon: {
            backgroundColor: "#000"
          }
        }}
      >
        <YourOwnComponent />
      </RBSheet>
    </View>
  );
}
Dynamic Bottom Sheet
renderItem = (item, index) => (
  <View>
    <Button title={`OPEN BOTTOM SHEET-${index}`} onPress={() => this[RBSheet + index].open()} />
    <RBSheet
      ref={ref => {
        this[RBSheet + index] = ref;
      }}
    >
      <YourOwnComponent onPress={() => this[RBSheet + index].close()} />
    </RBSheet>
  </View>
);

Props

PropsTypeDescriptionDefault
animationTypestringBackground animation ("none", "fade", "slide")"none"
heightnumberHeight of Bottom Sheet260
minClosingHeightnumberMinimum height of Bottom Sheet before close0
minStartHeightnumberMinimum starting height of the bottom sheet before opening0
openDurationnumberOpen Bottom Sheet animation duration300 (ms)
closeDurationnumberClose Bottom Sheet animation duration200 (ms)
closeOnDragDownbooleanUse gesture drag down to close Bottom Sheetfalse
dragFromTopOnlybooleanDrag only the top area of the draggableIcon to close Bottom Sheet instead of the whole contentfalse
closeOnPressMaskbooleanPress the area outside to close Bottom Sheettrue
closeOnPressBackbooleanPress back android to close Bottom Sheet (Android only)true
onOpenfunctionCallback function when Bottom Sheet has openednull
onClosefunctionCallback function when Bottom Sheet has closednull
customStylesobjectCustom style to Bottom Sheet{}
keyboardAvoidingViewEnabledbooleanEnable KeyboardAvoidingViewtrue (ios)

Available Custom Style

customStyles: {
  wrapper: {...}, // The Root of Component (You can change the `backgroundColor` or any styles)
  container: {...}, // The Container of Bottom Sheet
  draggableIcon: {...} // The Draggable Icon (If you set closeOnDragDown to true)
}

Methods

Method NameDescription
openOpen Bottom Sheet
closeClose Bottom Sheet

Note

  • If you combind RBSheet with react-native-gesture-handler, the components inside RBSheet will not fire onPress event on Android #37.
  • The demo source codes are in example folder.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Author

Made with ❤️ by NY Samnang.

Edited/updated by NoNam4.

Keywords

FAQs

Last updated on 21 Dec 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc