Skip to main content
Version: 1.0.0

Menu

Example banner

Implementation code

Wrap your app.js code with PortalProvider component to use menu.

import { PortalProvider, NativeProvider } from 'rn-nativeflow';
import Component from './path';

const App = () => {
return (
<NativeProvider>
<PortalProvider>
<Component/>
</PortalProvider>
</NativeProvider>
)
}
export default App;
  • Internally controlled checkbox
import { Menu, MenuItem, MenuItemLabel, Divider } from 'rn-nativeflow';
import { EllipsisVertical, Share2, User, Download, Eye } from 'lucide-react-native';

const Component = () => {
return (
<Menu
anchor={<EllipsisVertical color='#000' size={moderateScale(22)} />}
onSelect={(e) => console.log('select', e)}
placement='top'
>
<MenuItem name='Share' onPress={() => console.log("okk")}>
<Share2 color='#000' size={moderateScale(17)} />
<MenuItemLabel>
Share
</MenuItemLabel>
</MenuItem>
<Divider/>
<MenuItem name='Profile'>
<User color='#000' size={moderateScale(17)} />
<MenuItemLabel>
Profile
</MenuItemLabel>
</MenuItem>

<MenuItem name='Download'>
<Download color='#000' size={moderateScale(17)} />
<MenuItemLabel>
Download
</MenuItemLabel>
</MenuItem>

<MenuItem name='View'>
<Eye color='#000' size={moderateScale(17)} />
<MenuItemLabel>
View
</MenuItemLabel>
</MenuItem>
</Menu>
);
}
export default Component;
  • Externally controlled checkbox
import React,{ useState } from 'react';
import { Menu, MenuItem, MenuItemLabel, Divider } from 'rn-nativeflow';
import { EllipsisVertical, Share2, User, Download, Eye } from 'lucide-react-native';

const Component = () => {

const [isOpen, setIsOpen] = useState(false);

return (
<Menu
anchor={<EllipsisVertical color='#000' size={moderateScale(22)} />}
onSelect={(e) => console.log('select', e)}
placement='top'
disableBuiltInState
isOpen={isOpen}
onRequestOpen={() => useState(true)}
onRequestClose={() => useState(false)}
>
<MenuItem name='Share' onPress={() => console.log("okk")}>
<Share2 color='#000' size={moderateScale(17)} />
<MenuItemLabel>
Share
</MenuItemLabel>
</MenuItem>
<Divider/>
<MenuItem name='Profile'>
<User color='#000' size={moderateScale(17)} />
<MenuItemLabel>
Profile
</MenuItemLabel>
</MenuItem>

<MenuItem name='Download'>
<Download color='#000' size={moderateScale(17)} />
<MenuItemLabel>
Download
</MenuItemLabel>
</MenuItem>

<MenuItem name='View'>
<Eye color='#000' size={moderateScale(17)} />
<MenuItemLabel>
View
</MenuItemLabel>
</MenuItem>
</Menu>
);
}
export default Component;

Props

  • Menu Props
PropTypeDefaultDescription
placementtop, bottomtopIt sets the menu starting point relative to anchor
anchorJSX.ElementIt render the anchor to open the menu from
disableBuiltInStatebooleanfalseMenu control the state of visibility internally when disableBuiltInState=false
isOpenbooleanfalseIt change visibility of the menu on passing true or false but it only work when disableBuiltInState=true
onRequestOpenfunctionIt fired when user try to open the menu
onRequestClosefunctionIt fired when user try to close the menu
onSelectfunctionIt fired when user click on any menuItem and it gives the value of name prop of menu item
styleobjectHelps to change the styles of the menu container
  • Menu Item Props
PropTypeDefaultDescription
paddingVnumber12It sets the padding vertically on the menuItem
paddingHnumber15It sets the padding horizontally on the menuItem
gapnumber10It sets the gap between the children of the menuItem
styleobjectHelps to change the styles of the menuItem container
  • Menu Item Label Props
PropTypeDefaultDescription
fsnumber12Helps to change the font size of the MenuItemLabel
styleobjectHelps to change the styles of the MenuItemLabel