API

December 23, 2025 ยท View on GitHub

It provides methods to handle popup menus imperatively. The same methods are exposed to the context property menuActions. This can be retrieved by HOC withMenuContext that adds ctx property to your component. Then simply call props.ctx.menuActions.method().

Note: It is important that <MenuProvider /> is on the top of the component hierarchy (e.g. ScrollView should be inside of MenuProvider) and wraps all <Menu /> components. This is needed in order to solve z-index issues. The only known exception is when you use Modal - you need to place (additional) 'MenuProvider' inside of 'Modal' (see our ModalExample) Note: MenuProvider was formerly named MenuContext which is now deprecated.

Methods, menuActions context

Method NameArgumentsNotes
openMenunameOpens menu by name. Returns promise
toggleMenunameToggle menu by name. Returns promise
closeMenuCloses currently opened menu. Returns promise
isMenuOpenReturns true if any menu is open

Properties

OptionTypeOpt/RequiredDefaultNote
styleStyleOptionalStyle of wrapping View component. Same as customStyles.menuProviderWrapper but when both are present result style is a merge where this style has higher precedence.
customStylesObjectOptionalObject defining wrapper, touchable and text styles
backHandlerboolean|FunctionOptionalfalseWhether to close the menu when the back button is pressed or custom back button handler if a function is passed (RN >= 0.44 is required)
skipInstanceCheckbooleanOptionalfalseNormally your application should have only one menu provider (with exception as discussed above). If you really need more instances, set skipInstanceCheck to true to disable the check (and following warning message)
SafeAreaComponentComponentOptionalViewComponent to use for safe area wrapper. Can be set to SafeAreaView from React Native to restore the old behavior or any 3rd component like react-native-safe-area-context

Custom styles

To style <MenuProvider /> and backdrop component you can pass customStyles object prop with following keys:

Object keyTypeNotes
menuProviderWrapperStyleStyle of wrapping View component (formerly menuContextWrapper)
backdropStyleBackdrop View style
safeAreaStyleSafe area wrapper style. When not provided, default padding of 30 is applied to top and bottom

Note: Style type is any valid RN style parameter. Note: In addition to these styles we add also {flex:1}. You can disable it by e.g. style={{flex:0}}.

See more in custom styling example.

Handling of back button

To handle the back button you can pass backHandler prop with the following possible values:

ValueDescription
falseNo handling of back button press
trueThe menu will be closed
FunctionThe function will be called with MenuProvider instance as the first parameter. The function needs to return true to prevent application exit (or bubbling if there are other listeners registered). Read BackHandler documentation for more information.

See more in custom close on back example.

Root menu component defining menu name and providing menu events.

Methods

Method NameArgumentsNotes
openOpens menu. Returns promise
isOpenReturns wheter the menu is open or not
closeCloses menu. Returns promise

Properties

OptionTypeOpt/RequiredDefaultNote
nameStringOptionalauto-generatedUnique name of menu
openedBooleanOptionalDeclaratively states if menu is opened. When this prop is provided, menu is controlled and imperative API won't work.
rendererFunctionOptionalContextMenuDefines position, animation and basic menu styles. See renderers section for more details
rendererPropsObjectOptionalAdditional props which will be passed to the renderer

Events

Event NameArgumentsNotes
onSelectoptionValueTriggered when menu option is selected. When event handler returns false, the popup menu remains open
onOpenTriggered when menu is opened
onCloseTriggered when menu is closed
onBackdropPressTriggered when user press backdrop (outside of the opened menu)

Static Properties

Property nameTypeOpt/RequiredDefaultNote
debugBooleanOptionalfalseThis property enables debug logs

Static Functions

Function nameArgumentsReturnsNote
setDefaultRendererFunctionSets new default renderer. See renderers section for more details
setDefaultRendererPropsObjectSets new default renderer props

It defines position where the popup menu will be rendered. Menu can by opened by clicking on <MenuTrigger /> or by calling context methods.

Note: It is necessary that <MenuTrigger /> is a direct child of <Menu />.

Properties

OptionTypeOpt/RequiredDefaultNote
disabledBooleanOptionalfalseIndicates if trigger can be pressed
childrenElementsOptionalReact elements to render as menu trigger. Exclusive with text property
textStringOptionalText to be rendered. When this prop is provided, trigger's children won't be rendered
customStylesObjectOptionalObject defining wrapper, touchable and text styles
triggerOnLongPressBooleanOptionalfalseIf true, menu will trigger onLongPress instead of onPress
testIDStringOptionalUsed for e2e testing to get Touchable element

Events

Event NameArgumentsNotes
onPressTriggered when trigger is pressed (or longpressed depending on triggerOnLongPress)
onAlternativeActionTriggered when trigger is longpressed (or pressed depending on triggerOnLongPress)

Custom styles

To style <MenuTrigger /> component you can pass customStyles object prop with following keys:

Object keyTypeNotes
triggerOuterWrapperStyleStyle of outer View component
triggerWrapperStyleStyle of inner View component (can be overriden by style prop)
triggerTextStyleStyle of Text component (used when text shorthand option is defined)
TriggerTouchableComponentComponentTouchable component of trigger. Default value is TouchableHighlight for iOS and TouchableNativeFeedvack for Android
triggerTouchableObjectProperties passed to the touchable component (e.g. activeOpacity, underlayColor for TouchableHighlight)

Note: Style type is any valid RN style parameter.

See more in custom styling example and touchable example.

This component wrapps all menu options.

Note: It is necessary that <MenuOptions /> is a direct child of <Menu />.

Properties

OptionTypeOpt/RequiredDefaultNote
optionsContainerStyleStyleOptionalCustom styles for options container. Note: this option is deprecated, use customStyles option instead
renderOptionsContainerFuncOptionaloptions => optionsCustom render function for <MenuOptions />. It takes options component as argument and returns component. E.g.: options => <SomeCustomContainer>{options}</SomeCustomContainer> (Deprecated)
customStylesObjectOptionalObject defining wrapper, touchable and text styles

Custom styles

To style <MenuOptions /> and it's <MenuOption /> components you can pass customStyles object prop with following keys:

Object keyTypeNotes
optionsWrapperStyleStyle of wrapping MenuOptions component (can be overriden by style prop)
optionsContainerStyleStyle passed to the menu renderer (e.g. Animated.View)
optionWrapperStyleStyle of View component wrapping single option
optionTextStyleStyle of Text component (when text shorthand option is defined)
OptionTouchableComponentComponentTouchable component of option. Default value is TouchableHighlight for iOS and TouchableNativeFeedvack for Android
optionTouchableObjectProperties passed to the touchable component (e.g. activeOpacity, underlayColor for TouchableHighlight)

Note: optionWrapper, optionTouchable and optionText styles of particular menu option can be overriden by customStyles prop of <MenuOption /> component.

Note: In order to change customStyles dynamically, it is required that no child of MenuOptions stops the update (e.g. shouldComponentUpdate returning false).

Note: Style type is any valid RN style parameter.

See more in custom styling example and touchable example.

Wrapper component of menu option.

Properties

OptionTypeOpt/RequiredDefaultNote
valueAnyOptionalValue of option
childrenElementsOptionalReact elements to render as menu option. Exclusive with text property
textStringOptionalText to be rendered. When this prop is provided, option's children won't be rendered
disabledBooleanOptionalfalseIndicates if option can be pressed
disableTouchableBooleanOptionalfalseDisables Touchable wrapper (no on press effect and no onSelect execution) Note: Alternatively you don't have to use MenuOption at all if you want render something "non-selectable" in the menu (e.g. divider)
customStylesObjectOptionalObject defining wrapper, touchable and text styles
testIDStringOptionalUsed for e2e testing to get Touchable element. If disableTouchable=true, it is not available

Events

Event NameArgumentsNotes
onSelectTriggered when option is selected. When event handler returns false, the popup menu remains open. Note: If this event handler is defined, it suppress onSelect handler of <Menu />

Custom styles

To style <MenuOption /> component you can pass customStyles object prop with following keys:

Object keyTypeNotes
optionWrapperStyleStyle of wrapping View component.
optionTextStyleStyle of Text component (when text shorthand option is defined)
OptionTouchableComponentComponentTouchable component of option. Default value is TouchableHighlight for iOS and TouchableNativeFeedvack for Android
optionTouchableObjectProperties passed to the touchable component (e.g. activeOpacity, underlayColor for TouchableHighlight)

Note: Style type is any valid RN style parameter.

See more in custom styling example and touchable example.

Renderers

Renderers are react components which wraps MenuOptions and are responsible for menu position and animation. It is possible to extend menu and use custom renderer (see implementation of existing renderers or extension guide). All renderers can be found in renderers module.

Note: Renderers can be customized by props which can be passed through rendererProps option or setDefaultRendererProps static method.

ContextMenu (default)

Opens (animated) context menu over the trigger position. The ContextMenu.computePosition exports function for position calculation in case you would like to implement your own renderer (without special position calculation).

NotAnimatedContextMenu

Same as ContextMenu but without any animation.

SlideInMenu

Slides in the menu from the bottom of the screen.

Popover

Displays menu as a popover. Popover can be customized by following props:

OptionTypeOpt/RequiredDefaultNote
placementStringOptionalautoPosition of popover to the menu trigger - top | right | bottom | left | auto
preferredPlacementStringOptionaltopPreferred placement of popover - top | right | bottom | left. Applicable when placement is set to auto
anchorStyleStyleOptionalStyles passed to popover anchor component
openAnimationDurationNumberOptional225Duration of animation to show the popover
closeAnimationDurationNumberOptional195Duration of animation to hide the popover