Skip to main content

ActionSheetUI

Overview​

action-sheet-example

API Usage​

Step 1. create popup​

Using Default

ActionSheet.tsx
import { ActionSheetUI, createPopup } from 'react-native-global-components';
export default createPopup(ActionSheetUI);

or you can override default props

ActionSheet.tsx
import {
ActionSheetUI,
ActionSheetProps,
createPopup,
} from 'react-native-global-components';

const styles: ActionSheetProps['styles'] = StyleSheet.create({
// override default styles
});

export default createPopup((props: ActionSheetProps) => (
<ActionSheetUI {...props} styles={styles} />
));

Step 2. register portal​

App.tsx
const App = () => {
return (
<NavigationContainer>
<RootNavigator />
<ActionSheet.Portal />
</NavigationContainer>
);
};

Step 3. use anywhere​

ActionSheet.show({
actions: [
{
text: 'Action Item 1',
color: 'purple',
},
{
text: 'Action Item 2',
color: 'green',
},
],
});

Props​

title​

title text to show

TypeDefaultRequired
stringundefinedNO

description​

description text to show

TypeDefaultRequired
stringundefinedNO

actions​

actions to show. use ReactElement to customize item UI. see interface below

TypeDefaultRequired
(ActionSheetActionItem | ReactElement)[]undefinedYES
interface ActionSheetActionItem {
text: string;
color?: string;
onPress?: (text: string) => void;
style?: StyleProp<TextStyle>;
testID?: string;
}

cancelAction​

cancel button at bottom of action sheet. use ReactElement to customize item UI

TypeDefaultRequired
(ActionSheetActionItem | ReactElement){ text: 'Cancel' }NO

itemHeight​

height of action item

TypeDefaultRequired
number54NO

headerHeight​

height of header content area with title & description text. use Styles.header props below to edit styles.

default 80px if title or description props exists, unless 0px.

TypeDefaultRequired
number80 or 0NO

cancelText​

text of cancel button

TypeDefaultRequired
string'Cancel'NO

hideOnPressOverlay​

dismissable on press dim overlay

TypeDefaultRequired
booleantrueNO

animation​

custom withTimingConfig of ActionSheet sliding animation

TypeDefaultRequired
WithTimingConfig{ duration: 300,easing: Easing.bezier(0.25, 0.1, 0.25, 1) }NO

gap​

gap between action item group and cancel button.

TypeDefaultRequired
number8NO

bottomInset​

absolute bottom position of ActionSheet

TypeDefaultRequired
number0NO

touchableOpacityProps​

touchableOpacity props on action button to override default settings

TypeDefaultRequired
TouchableOpacityPropsundefinedNO

styles​

style object to override default style

TypeDefaultRequired
StylesundefinedNO
interface Styles {
title?: StyleProp<TextStyle>;
description?: StyleProp<TextStyle>;
header?: StyleProp<ViewStyle>;
actionGroup?: StyleProp<ViewStyle>;
action?: StyleProp<ViewStyle>;
cancelAction?: StyleProp<ViewStyle>;
container?: StyleProp<ViewStyle>;
divider?: StyleProp<ViewStyle>;
}