--- title: gluestack-ui ActionSheet | Installation, Usage & API description: Discover gluestack-ui’s ActionSheet for Expo, React & React Native. Create smooth action sheets with ease. Check our docs to learn more --- import { Tabs, TabItem } from '@/docs-components/tabs'; import ManualInstallationNote from '@/docs-components/manual-installation-note'; import { Table, TableHeader, TableCell, TableHeaderCell, TableBody, TableRow, } from '@/docs-components/table'; import { InlineCode } from '@/docs-components/inline-code'; import { AnatomyImage } from '@/docs-components/anatomy-image'; # ActionSheet Discover the ActionSheet component for Expo, React & React Native. Easily create intuitive action sheets in your app with gluestack-ui. Learn more in our detailed documentation! This is an illustration of **ActionSheet** component. /// {Example:basic} ///
## Installation ### Run the following command: ### Step 1: Install the following dependencies: ```bash npm i @expo/html-elements @legendapp/motion ``` ### Step 2: Copy and paste the following code into your project. ```jsx %%-- File: src/components/ui/actionsheet/index.tsx --%% ``` ### Step 3: Update the import paths to match your project setup. ## API Reference To use this component in your project, include the following import statement in your file. ```ts export default () => ( ); ```
```ts import { Actionsheet, ActionsheetBackdrop, ActionsheetContent, ActionsheetDragIndicator, ActionsheetDragIndicatorWrapper, ActionsheetItem, ActionsheetItemText, ActionsheetIcon, } from '@/components/ui/actionsheet'; ```
### Component Props This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration. #### Actionsheet It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. Name Type Default Description `isOpen` boolean false Whether the actionsheet is open. `onClose` () => void - Callback function when the actionsheet is closed. `snapPoints` number[] - Array of numbers representing the snap points in percentage. `initialFocusRef` React.RefObject<any> - Ref for the element that should be focused when the actionsheet opens. `finalFocusRef` React.RefObject<any> - Ref for the element that should be focused when the actionsheet closes.
> Note: If snapPoints are not provided to Actionsheet, then it's essential to set maxHeight to ActionsheetContent. #### ActionsheetBackdrop It is React Native's [Pressable](https://reactnative.dev/docs/pressable) component, created using [@legendapp/motion's](https://legendapp.com/open-source/motion/) `createMotionAnimatedComponent` function to add animation to the component. You can use any declarative animation library you prefer. #### ActionsheetContent It inherits all the properties of [@legendapp/motion's](https://legendapp.com/open-source/motion/) [Motion.View](https://legendapp.com/open-source/motion/overview/) component. With this Actionsheet component, you have the flexibility to use any declarative animation library that suits your needs. #### ActionsheetDragIndicatorWrapper It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. #### ActionsheetDragIndicator It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. #### ActionsheetItem It inherits all the properties of React Native's [Pressable](https://reactnative.dev/docs/pressable) component. #### ActionsheetItemText It inherits all the properties of React Native's [Text](https://reactnative.dev/docs/text) component. #### ActionsheetIcon It inherits all the properties of React Native's [View](https://reactnative.dev/docs/view) component. #### ActionsheetScrollView It inherits all the properties of React Native's [ScrollView](https://reactnative.dev/docs/scrollview) component. #### ActionsheetVirtualizedList It inherits all the properties of React Native's [VirtualizedList](https://reactnative.dev/docs/virtualizedlist) component. #### ActionsheetFlatList It inherits all the properties of React Native's [FlatList](https://reactnative.dev/docs/flatlist) component. #### ActionsheetSectionList It inherits all the properties of React Native's [SectionList](https://reactnative.dev/docs/sectionlist) component. #### ActionsheetSectionHeaderText It inherits all the properties of React Native's [Text](https://reactnative.dev/docs/text) component. > Note: While our Actionsheet component supports both ActionsheetScrollView and ActionsheetVirtualizedList, we recommend using VirtualizedList for better performance on large lists of items. The ScrollView option may cause performance issues on lists with many items. ### Features - Actionsheet has aria-modal set to true. - Actionsheet has role set to dialog. - When the Actionsheet opens, focus is trapped within it. - Pressing Esc closes the Actionsheet - Clicking on the overlay closes the Actionsheet - Scrolling is blocked on the elements behind the Actionsheet ### Accessibility We have outlined the various features that ensure the Actionsheet component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards. #### Keyboard - `Tab + Enter`: Triggers the actionsheet action. ### Screen Reader - VoiceOver: When the ActionSheet is focused, the screen reader will announce the button name. After entering the ActionSheet, it will read the content of the ActionSheet items. #### Keyboard - `Space`: Opens the actionsheet. - `Enter`: Opens/closes the actionsheet. - `Tab`: Moves focus to the next focusable element. - `Shift + Tab`: Moves focus to the previous focusable element. - `Esc`: Closes the actionsheet. ### Examples The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project. #### Keyboard handling Demonstrates a common UI pattern known as keyboard handling or keyboard scrolling, in which an input field is automatically scrolled into view when the user taps on it and the keyboard appears. This improves usability and ensures that the input field is always visible and accessible, even when the keyboard is blocking part of the screen. /// {Example:without-snappoints} /// /// {Example:with-snappoints} /// ### Selection with State Persistence This example demonstrates proper state handling when closing the actionsheet via drag gesture. Users can select a notification preference, and the selection is correctly saved whether they close by dragging or clicking the backdrop. /// {Example:state} /// /// {Example:icons} /// /// {Example:virtualized-list} /// /// {Example:flatlist} /// /// {Example:section-list} /// /// {Example:file-upload} ///