@expo/react-native-action-sheet vs react-native-actionsheet vs react-native-action-sheet
React Native Action Sheet Libraries Comparison
1 Year
@expo/react-native-action-sheetreact-native-actionsheetreact-native-action-sheetSimilar Packages:
What's 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.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
@expo/react-native-action-sheet157,9771,458177 kB226 days agoMIT
react-native-actionsheet15,9731,35415.6 kB104-MIT
react-native-action-sheet15,951183239 kB20-MIT
Feature Comparison: @expo/react-native-action-sheet vs react-native-actionsheet vs react-native-action-sheet

Integration with Expo

  • @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.

  • 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.

Customization and Styling

  • @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.

  • 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.

Community Support

  • @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.

  • 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.

Ease of Use

  • @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.

  • 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.

Performance

  • @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.

  • 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.

How to Choose: @expo/react-native-action-sheet vs react-native-actionsheet vs react-native-action-sheet
  • @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.

  • 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.

README for @expo/react-native-action-sheet

@expo/react-native-action-sheet

npm License: MIT Discord

React Native Action Sheet is a cross-platform React Native component that uses the native UIActionSheet on iOS and a pure JS implementation on Android.

| iOS | Android | Web | | -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------- | | | | |

Check out the example snack here!

Installation

npm install @expo/react-native-action-sheet

or

yarn add @expo/react-native-action-sheet

A basic ActionSheet Setup

1. Wrap your top-level component with <ActionSheetProvider />

ReactNativeActionSheet uses React context to allow your components to invoke the menu. This means your app needs to be wrapped with the ActionSheetProvider component first.

import { ActionSheetProvider } from '@expo/react-native-action-sheet';

export default function AppContainer() {
  return (
    <ActionSheetProvider>
      <App />
    </ActionSheetProvider>
  );
}

2. Call the showActionSheetWithOptions method with a hook or a higher order component.

// Using the provided hook
import { useActionSheet } from '@expo/react-native-action-sheet';

export default Menu() {
  const { showActionSheetWithOptions } = useActionSheet();

  const onPress = () => {
    const options = ['Delete', 'Save', 'Cancel'];
    const destructiveButtonIndex = 0;
    const cancelButtonIndex = 2;

    showActionSheetWithOptions({
      options,
      cancelButtonIndex,
      destructiveButtonIndex
    }, (selectedIndex: number) => {
      switch (selectedIndex) {
        case 1:
          // Save
          break;

        case destructiveButtonIndex:
          // Delete
          break;

        case cancelButtonIndex:
          // Canceled
      }});
  }

  return (
    <Button title="Menu" onPress={onPress}/>
  )
};

Alternatively, any component can use the higher order component to access the context and pass the showActionSheetWithOptions as a prop.

// Using a Higher Order Component to wrap your component
import { connectActionSheet } from '@expo/react-native-action-sheet';

function Menu({ showActionSheetWithOptions }) {
  /* ... */
}

export default connectActionSheet(Menu);

Menu component can now access the actionSheet prop as showActionSheetWithOptions.

Options

The goal of this library is to mimic the native iOS and Android ActionSheets as closely as possible.

This library can also be used in the browser with Expo for web.

Universal Props

| Name | Type | Description | | ------------------------ | -------------------------- | ------------------------------------------------------------- | | options | array of strings | A list of button titles (required) | | cancelButtonIndex | number | Index of cancel button in options | | cancelButtonTintColor | string | Color used for the change the text color of the cancel button | | destructiveButtonIndex | number or array of numbers | Indices of destructive buttons in options | | title | string | Title to show above the action sheet | | message | string | Message to show below the title | | tintColor | string | Color used for non-destructive button titles | | disabledButtonIndices | array of numbers | Indices of disabled buttons in options |

iOS Only Props

| Name | Type | Description | | -------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | anchor | number | iPad only option that allows for docking the action sheet to a node. See ShowActionSheetButton.tsx for an example on how to implement this. | | userInterfaceStyle | string | The interface style used for the action sheet, can be set to light or dark, otherwise the default system style will be used. |

Custom Action Sheet Only (Android/Web) Props

The below props allow modification of the Android ActionSheet. They have no effect on the look on iOS as the native iOS Action Sheet does not have options for modifying these options.

| Name | Type | Description | | ------------------ | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | icons | array of required images or icons | Show icons to go along with each option. If image source paths are provided via require, images will be rendered for you. Alternatively, you can provide an array of elements such as vector icons, pre-rendered Images, etc. | | tintIcons | boolean | Icons by default will be tinted to match the text color. When set to false, the icons will be the color of the source image. This is useful if you want to use multicolor icons. If you provide your own nodes/pre-rendered icons rather than required images in the icons array, you will need to tint them appropriately before providing them in the array of icons; tintColor will not be applied to icons unless they are images from a required source. | | textStyle | TextStyle | Apply any text style props to the options. If the tintColor option is provided, it takes precedence over a color text style prop. | | titleTextStyle | TextStyle | Apply any text style props to the title if present. | | messageTextStyle | TextStyle | Apply any text style props to the message if present. | | autoFocus | boolean | If true, this will give the first option screen reader focus automatically when the action sheet becomes visible. On iOS, this is the default behavior of the native action sheet. | | showSeparators | boolean | Show separators between items. On iOS, separators always show so this prop has no effect. | | containerStyle | ViewStyle | Apply any view style props to the container rather than use the default look (e.g. dark mode). | | separatorStyle | ViewStyle | Modify the look of the separators rather than use the default look. | | useModal | boolean | Defaults to false (true if autoFocus is also true) Wraps the ActionSheet with a Modal, in order to show in front of other Modals that were already opened (issue reference). | | destructiveColor | string | Modify color for text of destructive option. Defaults to #d32f2f. |

ActionSheetProvider Props

The following props can be set directly on the ActionSheetProvider

| Name | Type | Description | | ---------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | useCustomActionSheet | boolean | iOS only prop that uses the custom pure JS action sheet (Android/Web version) instead of the native ActionSheetIOS component. Defaults to false. | | useNativeDriver | boolean | Windows only option that provides the option to disable the native animation driver for React Native Windows projects targeting Windows 10 Version-1809 ; Build-10.0.17763.0 and earlier. useNativeDriver is supported in Version-1903 and later so if your project is targeting that, you don't need to set this prop. |

// example of using useCustomActionSheet on iOS
export default function AppContainer() {
  return (
    <ActionSheetProvider useCustomActionSheet={true}>
      <App />
    </ActionSheetProvider>
  );
}

Callback

The second parameter of the showActionSheetWithOptions function is a callback for when a button is selected. The callback takes a single argument which will be the zero-based index of the pressed option. You can check the value against your cancelButtonIndex to determine if the action was cancelled or not.

function onButtonPress(selectedIndex: number) {
  // handle it!
}

Try it out

Try it in Expo Snack: https://snack.expo.dev/@expo-action-sheet/example.

Example

See the example app.

Usage

$ cd example
$ yarn

// build simulator
$ yarn ios
$ yarn android

// web
$ yarn web

Development

Setup

$ git clone git@github.com:expo/react-native-action-sheet.git
$ cd react-native-action-sheet
$ yarn

Build

We use bob.

$ yarn build

Lint & Format

// tsc
$ yarn type-check

// ESLint + Prettier
$ yarn lint