Home

Awesome

react-native-material-menu · npm license

Pure JavaScript material menu component for React Native with automatic RTL support.

<img src="https://media.giphy.com/media/3ov9jUvQH4U82JGNRC/giphy.gif" />

Install

Using yarn

yarn add react-native-material-menu

or using npm

npm install --save react-native-material-menu

Usage example

import React, { useState } from 'react';

import { View, Text } from 'react-native';
import { Menu, MenuItem, MenuDivider } from 'react-native-material-menu';

export default function App() {
  const [visible, setVisible] = useState(false);

  const hideMenu = () => setVisible(false);

  const showMenu = () => setVisible(true);

  return (
    <View style={{ height: '100%', alignItems: 'center', justifyContent: 'center' }}>
      <Menu
        visible={visible}
        anchor={<Text onPress={showMenu}>Show menu</Text>}
        onRequestClose={hideMenu}
      >
        <MenuItem onPress={hideMenu}>Menu item 1</MenuItem>
        <MenuItem onPress={hideMenu}>Menu item 2</MenuItem>
        <MenuItem disabled>Disabled item</MenuItem>
        <MenuDivider />
        <MenuItem onPress={hideMenu}>Menu item 4</MenuItem>
      </Menu>
    </View>
  );
}

Menu

namedescriptiontypedefault
childrenComponents rendered in menu (required)ReactNode-
anchorButton component (required)ReactNode-
visibleWhether the Menu is currently visibleBoolean-
styleMenu styleViewStyle-
onRequestCloseCallback when menu has become hiddenFunction-
animationDurationChanges show/hide animation durationNumber300

MenuItem

namedescriptiontypedefault
childrenRendered children (required)ReactNode-
disabledDisabled flagBooleanfalse
disabledTextColorDisabled text colorString'#bdbdbd'
onPressCalled function on pressFunction-
styleContainer styleViewStyle-
textStyleText styleTextStyle-
pressColorPressed colorString'#e0e0e0'

Children must be based on <Text> component (like text itself, strings, react-native-vector-icons or expo icons) otherwise you may get an error on a real device.

MenuDivider

namedescriptiontypedefault
colorLine colorString'rgba(0,0,0,0.12)'

Pietile native kit

Also take a look at other our components for react-native - pietile-native-kit

License

MIT License. © Maksim Milyutin 2017-2021