A simple popup menu for React Native android apps.
npm install react-native-android-popup-menu
or
yarn add react-native-android-popup-menu
import PopupMenu from 'react-native-android-popup-menu';
export default function MyApp() {
// ...
const onSelectItem = (item, index) => {
if (item === "itemSelected") {
console.log("selected item:", index);
}
};
const options = [
"Edit",
"Delete"
];
return (
// ...
<PopupMenu
onPress={onSelectItem}
items={options}
/>
);
}
Key | Type | Required | Default Value |
---|---|---|---|
onPress | (event: PopupEvent | string, index: number | undefined) => void | True | undefined |
items | string[] | True | undefined |
mode | ModeOption | False | highlight |
icon | MaterialIcons.glyphMap | False | more-vert |
iconSize | number | False | 24 |
iconComponent | ({ iconRef, ...props }) => React.ReactNode | False | undefined |
iconColor | ColorValue | False | #222222 |
underlayColor | ColorValue | False | rgba(0,0,0,0.2) |
containerStyle | StyleProp<ViewStyle> | False | undefined |
buttonStyle | StyleProp<ViewStyle> | False | undefined |
iconStyle | StyleProp<TextStyle> | False | undefined |
ModeOption
export type ModeOption =
| 'opacity'
| 'highlight'
| 'without-feedback'
| 'native';
PopupEvent
export type PopupEvent = 'dismissed' | 'itemSelected';
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
Made with create-react-native-library