Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Your Own Component To Bottom Sheet Whatever You Want (Android and iOS)

License

NotificationsYou must be signed in to change notification settings

nysamnang/react-native-raw-bottom-sheet

Repository files navigation

Hooray! The new version 3 has been released.

Please pay close attention if you are upgrading the RBSheet from version 2 to version 3.

  • Functional Components: Starting from v3.0.0, RBSheet has been completely rewritten using Functional Components. This improves performance and aligns with modern React practices.
  • Prop Removal & Renaming: Several props have been removed and renamed for improved clarity and maintainability. Please refer to the updated documentation for a complete list of available props and their intended behavior.

NPM Versionnpm downloadsGitHub Actions Workflow Statuscodecov

  • 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
  • Millions of Downloads
Showcase iOSShowcase Android

Installation

npm i react-native-raw-bottom-sheet --save

or

yarn add react-native-raw-bottom-sheet

Example

Please check theexample folder to explore more example codes.

Single Bottom Sheet

importReact,{useRef}from'react';import{View,Button}from'react-native';importRBSheetfrom'react-native-raw-bottom-sheet';exportdefaultfunctionExample(){constrefRBSheet=useRef();return(<Viewstyle={{flex:1}}><Buttontitle="OPEN BOTTOM SHEET"onPress={()=>refRBSheet.current.open()}/><RBSheetref={refRBSheet}useNativeDriver={true}customStyles={{wrapper:{backgroundColor:'transparent',},draggableIcon:{backgroundColor:'#000',},}}customModalProps={{animationType:'slide',statusBarTranslucent:true,}}customAvoidingViewProps={{enabled:false,}}><YourOwnComponent/></RBSheet></View>);}

Multiple Bottom Sheet

constrefRBSheet=useRef([]);constrenderItem=({item, index})=>{return(<View><TouchableOpacitystyle={styles.button}onPress={()=>refRBSheet.current[index].open()}><Textstyle={styles.buttonText}>ITEM{item+1}</Text></TouchableOpacity><RBSheetref={ref=>(refRBSheet.current[index]=ref)}><Viewstyle={styles.bottomSheetContainer}><Textstyle={styles.bottomSheetText}>I AM ITEM{item+1}</Text></View></RBSheet></View>);};

Props

PropsTypeDescriptionDefault
heightnumberThe height of bottom sheet.260
openDurationnumberDuration of the animation when opening bottom sheet.300 (ms)
closeDurationnumberDuration of the animation when closing bottom sheet.200 (ms)
closeOnPressMaskbooleanPress the outside area (mask) to close bottom sheet.true
closeOnPressBackbooleanPress hardware back android to close bottom sheet (Android only).false
draggablebooleanEnable the drag-down gesture to close the bottom sheet.false
dragOnContentbooleanThe draggable is only worked on the draggable icon. Set this totrue
if you want to drag on the content as well (doesn't work with ScrollView).
false
useNativeDriverbooleanUse the native driver to run smoother animation.false
customStylesobjectAddcustom styles to bottom sheet.{}
customModalPropsobjectAddcustom props to modal.{}
customAvoidingViewPropsobjectAddcustom props to KeyboardAvoidingView.{}
onOpenfunctionCallback function that will be called after the bottom sheet has been opened.null
onClosefunctionCallback function that will be called after the bottom sheet has been closed.null

Available Custom Style

customStyles:{wrapper:{...},// The Root of component (Change the mask's background color here).container:{...},// The Container of bottom sheet (The animated view that contains your component).draggableIcon:{...}// The style of Draggable Icon (If you set `draggable` to `true`).}

Methods

Method NameDescriptionUsage
openThe method to open bottom sheet.refRBSheet.current.open()
closeThe method to close bottom sheet.refRBSheet.current.close()

CONTRIBUTING

I'm really glad you're reading this, because we need volunteer developers to help bring this project to life.

How to contribute:

  1. Clone this repository
  2. Open project, then runyarn to install devDependencies
  3. Add your magic code for contribution
  4. Test your code
    • Navigate toexample folder
    • Runyarn &yarn start to run the example project
    • Test your code inexample/App.js
  5. UpdateREADME.md to update documentation (Optional)
  6. Write unit testing in__tests__ folder (Optional)
  7. Updateindex.d.ts to update typing (Optional)
  8. Make a pull request, Genius!

License

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

Author

Made with ❤️ byNY Samnang.

Packages

No packages published

Contributors16


[8]ページ先頭

©2009-2025 Movatter.jp