Skip to main content

Menu

Example banner

Implementation code

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

import { PortalProvider, NativeProvider } from '@nexara/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 '@nexara/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 '@nexara/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

PropTypeDefaultDescription
placement'top' | 'bottom''top'Determines the position of the menu relative to the anchor.
anchorJSX.ElementThe component that triggers the menu when pressed.
disableBuiltInStatebooleanfalseIf true, the menu's open/close state must be controlled externally.
isOpenbooleanfalseControls the visibility of the menu (used only when disableBuiltInState is true).
onRequestOpen() => voidCalled when the menu tries to open (when using external state).
onRequestClose() => voidCalled when the menu tries to close (when using external state).
onSelect(name: string) => voidTriggered when a MenuItem is selected, returns the item's name.
styleViewStyleCustom styles for the menu container.
PropTypeDefaultDescription
paddingVnumber11Vertical padding for the MenuItem.
paddingHnumber17Horizontal padding for the MenuItem.
gapnumber12Gap between the children elements within the MenuItem.
styleViewStyleCustom styles for the MenuItem container.
PropTypeDefaultDescription
fsnumberCustom font size (overrides textVariant).
textVariant'h1' to 'h6''h5'Variant of the text style, controls font size and weight via StyledText.
styleViewStyleCustom styles to apply to the label.