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

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.

License

NotificationsYou must be signed in to change notification settings

ammarahm-ed/react-native-actions-sheet

 
 

Repository files navigation

Quick Preview

Installation Guide

npm install react-native-actions-sheet --save

OR

yarn add react-native-actions-sheet

How to use

Create your ActionSheet component and register it with a unique id. Remember that you do not need to render the ActionSheet in any components.

importReactfrom"react";importActionSheet,{SheetManager,SheetProps,registerSheet,}from"react-native-actions-sheet";functionMySheet(props:SheetProps){return(<ActionSheetid={props.sheetId}><View><Text>Hello World</Text></View></ActionSheet>);}// Register your Sheet component.registerSheet("mysheet",MySheet);exportdefaultMySheet;

Create asheets.tsx orsheets.js file.

// Import all the sheets here as followsimport"mysheet.tsx";export{};

InApp.js importsheets.tsx and wrap your app inSheetProvider.

import{SheetProvider}from"react-native-actions-sheet";import"sheets.tsx";// herefunctionApp(){return(<SheetProvider>{// your app components}</SheetProvider>);}

Now you can open the ActionSheet from anywhere in the app.

SheetManager.show("mysheet");

Want to pass some data on opening the sheet or update the state?

SheetManager.show("mysheet",{value:"data"});<ActionSheetonBeforeShow={(data)=>{setData(data);}}id="helloworld_sheet">

Hiding the sheet is easy. Enable gestures or do the following.

awaitSheetManager.hide("mysheet");

Close all opened ActionSheets

SheetManager.hideAll();

Showing ActionSheet withoutSheetProvider

You can also show the sheet without SheetProvider.

<ActionSheetid="mysheet"><View><Text>Hello World</Text></View></ActionSheet>

And then show it;

SheetManager.show("mysheet");

Features

  1. Cross Platform (iOS and Android)
  2. Native Animations & Performance
  3. Identical Working on Android and iOS
  4. Control ActionSheet withGestures
  5. Raw ActionSheet - You can Add Anything
  6. Allow ActionSheet to be partially shown when opened
  7. Support TextInputs
  8. Coolbounce effect on open.
  9. Tablets and iPads
  10. Horizontal Layout
  11. Nested Scrolling or Scrollable Content.
  12. Virtualization Support
  13. Global Sheet Manager
  14. Proper resizing on Android & iOS on Keyboard show/hide.

Consider supporting with a ⭐️star on GitHub

If you are using the library in one of your projects, consider supporting with a star. It takes a lot of time and effort to keep this maintained and address issues and bugs. Thank you.

Reference

Props

id

A unique id for the ActionSheet. You must set this if you are usingSheetManager.

TypeRequired
idfalse

ref

Assigns a ref to ActionSheet component to use methods.

TypeRequired
reffalse

testID

Test ID for unit testing

TypeRequired
stringno

isModal

Set this to false to use a simple View instead of a Modal to show the ActionSheet.

TypeRequired
booleanno

default:true

initialOffsetFromBottom

Use if you want to show the ActionSheet Partially on Opening. **RequiresgestureEnabled=true **

TypeRequired
numberno

Default:1

extraScroll

Normally when the ActionSheet is fully opened, a small portion from the bottom is hidden by default. Use this prop if you want the ActionSheet to hover over the bottom of screen and not hide a little behind it.

TypeRequired
numberno

Default:0

indicatorStyle

Style the top indicator bar in ActionSheet.

TypeRequired
ViewStyleno

containerStyle

Any custom styles for the container.

TypeRequired
Objectno

delayActionSheetDraw

Delay draw of ActionSheet on open for android.

TypeRequired
booleanno

Default:false

delayActionSheetDrawTime

Delay draw of ActionSheet on open for android time.

TypeRequired
number (ms)no

Default:50

CustomHeaderComponent

Your custom header component. Using this will hide the default indicator.

TypeRequired
React. ReactNodeno

ExtraOverlayComponent

Render a component over the ActionSheet. Useful for rendering Toast components with which user can interact.

TypeRequired
React. ReactNodeno

headerAlwaysVisible

Keep the header always visible even when gestures are disabled.

TypeRequired
booleanno

Default:false

animated

Animate the opening and closing of ActionSheet.

TypeRequired
booleanno

Default:true

openAnimationSpeed

Speed of opening animation. Higher means the ActionSheet will open more quickly. Use it in combination withbounciness prop to have optimize the bounce/spring effect on ActionSheet open.

TypeRequired
numberno

Default:12

closeAnimationDuration

Duration of closing animation.

TypeRequired
numberno

Default:300

gestureEnabled

Enables gesture control of ActionSheet

TypeRequired
booleanno

Default:false

closeOnTouchBackdrop

Control closing ActionSheet by touching on backdrop.

TypeRequired
booleanno

Default:true

bounceOnOpen

Bounces the ActionSheet on open.

TypeRequired
booleanno

Default:false

bounciness

How much you want the ActionSheet to bounce when it is opened.

TypeRequired
numberno

Default:8

springOffset

When touch ends and user has not moved farther from the set springOffset, the ActionSheet will return to previous position.

TypeRequired
numberno

Default:50

elevation

Add elevation to the ActionSheet container.

TypeRequired
numberno

Default:0

indicatorColor

Color of the gestureEnabled Indicator.

TypeRequired
stringno

Default:"#f0f0f0"

overlayColor

Color of the overlay/backdrop.

TypeRequired
stringno

Default:"black"

defaultOverlayOpacity

Default opacity of the overlay/backdrop.

TypeRequired
number 0 - 1no

Default:0.3

closable

Prevent ActionSheet from closing on gesture or tapping on backdrop. Instead snap it tobottomOffset location

TypeRequired
booleanno

Default:true

bottomOffset

Snap ActionSheet to this location ifclosable is set to false. By default it will snap to the location on first open.

TypeRequired
numberno

Default:0

keyboardShouldPersistTaps

Setting the keyboard persistence of theScrollView component. Should be one of "never", "always" or "handled"

TypeRequired
stringno

Default:never

keyboardHandlerEnabled

Allow to choose will content change position when keyboard is visible.This is enabled by default.

TypeRequired
booleanno

Default:true

keyboardDismissMode

Set how keyboard should behave on tapping the ActionSheet.

TypeRequired
"on-drag""none""interactive"no

Default :"none"

statusBarTranslucent

Determine whether the modal should go under the system statusbar.

TypeRequired
booleanno

Default:true

closeOnPressBack

Will the ActionSheet close onhardwareBackPress event.

TypeRequired
booleanno

Default:true

drawUnderStatusBar

Allow ActionSheet to draw under the StatusBar. This is enabled by default.

TypeRequired
booleanno

Default:false

onPositionChanged(onReachedTop:boolean)

Event called when position of ActionSheet changes.

TypeRequired
functionno

onClose

Event called when the ActionSheet closes.

TypeRequired
functionno

onOpen

An event called when the ActionSheet Opens.

TypeRequired
functionno

Methods

Methods require you to set a ref on ActionSheet Component.

handleChildScrollEnd()

If your component includes any child ScrollView/FlatList you must attach this method to all scroll end callbacks.

<ScrollViewref={scrollViewRef}nestedScrollEnabled={true}onMomentumScrollEnd={()=>actionSheetRef.current?.handleChildScrollEnd()}.....

show()

Opens the ActionSheet.

importActionSheetfrom"react-native-actions-sheet";importReact,{createRef}from"react";constactionSheetRef=createRef();// First create a ref on your <ActionSheet/> Component.<ActionSheetref={actionSheetRef}/>;// then later in your function to open the ActionSheet:actionSheetRef.current?.show();

hide()

Closes the ActionSheet.

importActionSheetfrom"react-native-actions-sheet";importReact,{createRef}from"react";constactionSheetRef=createRef();// First create a ref on your <ActionSheet/> Component.<ActionSheetref={actionSheetRef}/>;// then later in your function to open the ActionSheet:actionSheetRef.current?.hide();

setModalVisible

ActionSheet can be opened or closed using its ref.

importActionSheetfrom"react-native-actions-sheet";importReact,{createRef}from"react";constactionSheetRef=createRef();// First create a ref on your <ActionSheet/> Component.<ActionSheetref={actionSheetRef}/>;// then later in your function to open the ActionSheet:actionSheetRef.current?.setModalVisible();

setModalVisible(visible)

It's also possible to explicitly either show or hide modal.

importActionSheetfrom"react-native-actions-sheet";importReact,{createRef}from"react";constactionSheetRef=createRef();// First create a ref on your <ActionSheet/> Component.<ActionSheetref={actionSheetRef}/>;// then to show modal useactionSheetRef.current?.setModalVisible(true);// and later you may want to hide it usingactionSheetRef.current?.setModalVisible(false);

snapToOffset(offset:number)

When the ActionSheet is open, you can progammatically snap it to different offsets.

importActionSheetfrom"react-native-actions-sheet";importReact,{createRef}from"react";constactionSheetRef=createRef();// First create a ref on your <ActionSheet/> Component.<ActionSheetref={actionSheetRef}/>;// snap to this location on screenactionSheetRef.current?.snapToOffset(200);actionSheetRef.current?.snapToOffset(150);actionSheetRef.current?.snapToOffset(300);

Nested scrolling on android

Nested scrolling on android is disabled by default. You can enable it as done below.

importActionSheetfrom"react-native-actions-sheet";constApp=()=>{constactionSheetRef=useRef();return(<ActionSheetref={actionSheetRef}><ScrollViewnestedScrollEnabled={true}onMomentumScrollEnd={()=>actionSheetRef.current?.handleChildScrollEnd()}/></ActionSheet>);};

Find this library useful? ❤️

Support it by donating or joining stargazers for this repository. ⭐️ and follow me for my next creations!

MIT Licensed

Notesnook Logo

About

A Cross Platform(Android, iOS & Web) ActionSheet with a flexible api, native performance and zero dependency code for react native. Create anything you want inside ActionSheet.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

    Packages

    No packages published

    [8]ページ先頭

    ©2009-2025 Movatter.jp