react-native-action-sheet vs @expo/react-native-action-sheet vs react-native-actionsheet
React Native Action Sheet Libraries
react-native-action-sheet@expo/react-native-action-sheetreact-native-actionsheetSimilar Packages:

React Native Action Sheet Libraries

Action sheet libraries in React Native provide a way to present users with a set of options or actions related to a specific context. They are commonly used to prompt users for decisions or to select from a list of choices, enhancing user interaction and experience. These libraries differ in terms of features, ease of use, and integration with React Native applications, making it essential to understand their unique offerings before choosing one for your project.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
react-native-action-sheet15,861185239 kB20-MIT
@expo/react-native-action-sheet01,568177 kB32a year agoMIT
react-native-actionsheet01,35815.6 kB104-MIT

Feature Comparison: react-native-action-sheet vs @expo/react-native-action-sheet vs react-native-actionsheet

Integration with Expo

  • react-native-action-sheet:

    This package is not tailored for Expo, meaning it may require additional setup or configuration to work within an Expo environment. It is more suited for bare React Native projects where developers have more control over the native code.

  • @expo/react-native-action-sheet:

    This package is specifically designed for Expo applications, ensuring seamless compatibility and ease of use within the Expo framework. It leverages Expo’s APIs and simplifies the process of implementing action sheets without additional configuration.

  • react-native-actionsheet:

    Similar to react-native-action-sheet, this package is also not designed specifically for Expo, requiring developers to manage native dependencies if using in an Expo project.

Customization and Styling

  • react-native-action-sheet:

    Provides extensive customization options, allowing developers to style the action sheet to fit their application's design. It supports various props for modifying the appearance and behavior, making it highly adaptable.

  • @expo/react-native-action-sheet:

    Offers limited customization options, focusing on a straightforward implementation. It provides basic styling capabilities, but developers may find it restrictive if they want a highly customized action sheet.

  • react-native-actionsheet:

    This package also allows for some level of customization, but it is generally more simplistic compared to react-native-action-sheet. It is suitable for projects that require basic styling without extensive customization.

Community Support

  • react-native-action-sheet:

    This package has a large community and extensive documentation, making it easier to find solutions to common issues. Its popularity ensures that it is actively maintained and updated.

  • @expo/react-native-action-sheet:

    Being part of the Expo ecosystem, it benefits from the community and resources available for Expo users. However, it may have a smaller user base compared to more established libraries.

  • react-native-actionsheet:

    While it has a decent user base, its community support is not as robust as react-native-action-sheet. Documentation is available, but developers might encounter fewer resources when troubleshooting.

Ease of Use

  • react-native-action-sheet:

    This package has a moderate learning curve, requiring some understanding of React Native’s component structure. However, once set up, it offers a straightforward API for implementation.

  • @expo/react-native-action-sheet:

    Designed for simplicity, this package is easy to implement, especially for developers already familiar with Expo. It requires minimal setup, making it ideal for quick projects.

  • react-native-actionsheet:

    This package is the easiest to implement among the three, focusing on core functionality without complex configurations. It is suitable for developers looking for a quick and simple solution.

Performance

  • react-native-action-sheet:

    This package is also performance-oriented, but the level of customization may introduce some overhead depending on how it is implemented. Developers should be mindful of performance implications when using extensive styles or configurations.

  • @expo/react-native-action-sheet:

    Optimized for performance within the Expo environment, it ensures smooth interactions without significant overhead. It is lightweight and efficient for most use cases.

  • react-native-actionsheet:

    Lightweight and designed for quick interactions, this package performs well in most scenarios. It is suitable for applications where performance is a priority and minimal features are needed.

How to Choose: react-native-action-sheet vs @expo/react-native-action-sheet vs react-native-actionsheet

  • react-native-action-sheet:

    Select this package if you are looking for a widely-used, community-supported solution that offers flexibility and customization options. It is suitable for projects that require a more traditional React Native setup without Expo, and it allows for extensive styling and configuration.

  • @expo/react-native-action-sheet:

    Choose this package if you are using Expo and want a simple, straightforward implementation that integrates seamlessly with the Expo ecosystem. It provides a native action sheet experience with minimal setup and is optimized for Expo applications.

  • react-native-actionsheet:

    Opt for this package if you need a lightweight solution with a focus on simplicity and performance. It is ideal for developers who want a quick implementation with basic features and minimal dependencies, making it a good choice for smaller projects.

README for react-native-action-sheet

react-native-action-sheet npm version MIT Platform - Android and iOS

React native action sheet with native android (using the built-in AlertDialog)

This module simply return the ActionSheetIOS if the device on iOS

iOSAndroid

Table of contents

IMPORTANT ! Package name on npm is now react-native-action-sheet

Install

npm install react-native-action-sheet@latest --save react-native link react-native-action-sheet

if react native < 0.47

npm install @yfuks/react-native-action-sheet@0.0.3 --save react-native link @yfuks/react-native-action-sheet

Android

The react-native link command above should do everything you need, but if for some reason it does not work, you can replicate its effects manually by making the following changes.

// file: android/settings.gradle
...

include ':react-native-action-sheet'
project(':react-native-action-sheet').projectDir = new File(settingsDir, '../node_modules/react-native-action-sheet/android')
// file: android/app/build.gradle
...

dependencies {
    ...
    compile project(':react-native-action-sheet')
}
// file: android/app/src/main/java/com/<...>/MainApplication.java
...

import com.actionsheet.ActionSheetPackage; // <-- add this import

public class MainApplication extends Application implements ReactApplication {
    @Override
    protected List<ReactPackage> getPackages() {
        return Arrays.<ReactPackage>asList(
            new MainReactPackage(),
            new ActionSheetPackage() // <-- add this line
        );
    }
...
}

(Optional) Style customization

You can change the style of the dialog by editing nodes_modules/react-native-action-sheet/android/src/main/res/values/style.xml

Usage

import ActionSheet from 'react-native-action-sheet';
import { Platform } from 'react-native';

var BUTTONSiOS = [
  'Option 0',
  'Option 1',
  'Option 2',
  'Delete',
  'Cancel'
];

var BUTTONSandroid = [
  'Option 0',
  'Option 1',
  'Option 2'
];

var DESTRUCTIVE_INDEX = 3;
var CANCEL_INDEX = 4;

ActionSheet.showActionSheetWithOptions({
  options: (Platform.OS == 'ios') ? BUTTONSiOS : BUTTONSandroid,
  cancelButtonIndex: CANCEL_INDEX,
  destructiveButtonIndex: DESTRUCTIVE_INDEX,
  tintColor: 'blue'
},
(buttonIndex) => {
  console.log('button clicked :', buttonIndex);
});

Methods

For the iOS implementation see ActionSheetIOS

showActionSheetWithOptions (Android)

/**
 * Display the native action sheet
 */

static showActionSheetWithOptions(options, callback);

@note: on Android in case of a touch outside the ActionSheet or the button back is pressed the buttonIndex value is 'undefined'

options

optioniOSAndroidInfo
optionsOKOK(array of strings) - a list of button titles (required on iOS)
cancelButtonIndexOK-(int) - index of cancel button in options (useless in android since we have back button)
destructiveButtonIndexOK-(int) - index of destructive button in options (same as above)
titleOKOK(string) - a title to show above the action sheet
messageOK-(string) - a message to show below the title
tintColorOK-(string) - a color to set to the text (defined by processColor)