React Menu API

The Menu UI component is a panel with clickable items. A click on an item opens a drop-down menu, which can contain several submenus.

import Menu from "devextreme-react/menu"
Selector: Menu

Configuration

An object defining configuration properties for the Menu UI component.

Name Description
accessKey

Specifies the shortcut key that sets focus on the UI component.

activeStateEnabled

Specifies whether the UI component changes its visual state as a result of user interaction.

adaptivityEnabled

Specifies whether adaptive rendering is enabled. This property is in effect only if the orientation is "horizontal".

animation

Configures UI component visibility animations. This object contains two fields: show and hide.

cssClass

Specifies the name of the CSS class to be applied to the root menu level and all submenus.

dataSource

Binds the UI component to data.

disabled

Specifies whether the UI component responds to user interaction.

disabledExpr

Specifies the name of the data source item field whose value defines whether or not the corresponding UI component item is disabled.

displayExpr

Specifies the data field whose values should be displayed.

elementAttr

Specifies the global attributes to be attached to the UI component's container element.

focusStateEnabled

Specifies whether the UI component can be focused using keyboard navigation.

height

Specifies the UI component's height.

hideSubmenuOnMouseLeave

Specifies whether or not the submenu is hidden when the mouse pointer leaves it.

hint

Specifies text for a hint that appears when a user pauses on the UI component.

hoverStateEnabled

Specifies whether the UI component changes its state when a user pauses on it.

itemComponent

An alias for the itemTemplate property specified in React. Accepts a custom component. Refer to Using a Custom Component for more information.

itemRender

An alias for the itemTemplate property specified in React. Accepts a rendering function. Refer to Using a Rendering Function for more information.

items

Holds an array of menu items.

itemsExpr

Specifies which data field contains nested items.

itemTemplate

Specifies a custom template for items.

onContentReady

A function that is executed when the UI component is rendered and each time the component is repainted.

onDisposing

A function that is executed before the UI component is disposed of.

onInitialized

A function used in JavaScript frameworks to save the UI component instance.

onItemClick

A function that is executed when a collection item is clicked or tapped.

onItemContextMenu

A function that is executed when a collection item is right-clicked or pressed.

onItemRendered

A function that is executed after a collection item is rendered.

onOptionChanged

A function that is executed after a UI component property is changed.

onSelectionChanged

A function that is executed when a collection item is selected or selection is canceled.

onSubmenuHidden

A function that is executed after a submenu is hidden.

onSubmenuHiding

A function that is executed before a submenu is hidden.

onSubmenuShowing

A function that is executed before a submenu is displayed.

onSubmenuShown

A function that is executed after a submenu is displayed.

orientation

Specifies whether the menu has horizontal or vertical orientation.

rtlEnabled

Switches the UI component to a right-to-left representation.

selectByClick

Specifies whether an item is selected if a user clicks it.

selectedExpr

Specifies the name of the data source item field whose value defines whether or not the corresponding UI component items is selected.

selectedItem

The selected item object.

selectionMode

Specifies the selection mode supported by the menu.

showFirstSubmenuMode

Specifies properties for showing and hiding the first level submenu.

showSubmenuMode

Specifies properties of submenu showing and hiding.

submenuDirection

Specifies the direction at which the submenus are displayed.

tabIndex

Specifies the number of the element when the Tab key is used for navigating.

visible

Specifies whether the UI component is visible.

width

Specifies the UI component's width.

Methods

This section describes members used to manipulate the UI component.

Name Description
beginUpdate()

Postpones rendering that can negatively affect performance until the endUpdate() method is called.

defaultOptions(rule)

Specifies the device-dependent default configuration properties for this component.

dispose()

Disposes of all the resources allocated to the Menu instance.

element()

Gets the root UI component element.

endUpdate()

Refreshes the UI component after a call of the beginUpdate() method.

focus()

Sets focus on the UI component.

getDataSource()

Gets the DataSource instance.

getInstance(element)

Gets the instance of a UI component found using its DOM node.

instance()

Gets the UI component's instance. Use it to access other methods of the UI component.

off(eventName)

Detaches all event handlers from a single event.

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

on(eventName, eventHandler)

Subscribes to an event.

on(events)

Subscribes to events.

option()

Gets all UI component properties.

option(optionName)

Gets the value of a single property.

option(optionName, optionValue)

Updates the value of a single property.

option(options)

Updates the values of several properties.

registerKeyHandler(key, handler)

Registers a handler to be executed when a user presses a specific key.

repaint()

Renders the component again without reloading data. Use the method to update the component's markup and appearance dynamically.

resetOption(optionName)

Resets a property to its default value.

selectItem(itemElement)

Selects an item found using its DOM node.

unselectItem(itemElement)

Cancels the selection of an item found using its DOM node.

Events

This section describes events fired by this UI component.

Name Description
contentReady

Raised when the UI component is rendered and each time the component is repainted.

disposing

Raised before the UI component is disposed of.

initialized

Raised only once, after the UI component is initialized.

itemClick

Raised when a collection item is clicked or tapped.

itemContextMenu

Raised when a collection item is right-clicked or pressed.

itemRendered

Raised after a collection item is rendered.

optionChanged

Raised after a UI component property is changed.

selectionChanged

Raised when a collection item is selected or selection is canceled.

submenuHidden

Raised after a submenu is hidden.

submenuHiding

Raised before a submenu is hidden.

submenuShowing

Raised before a submenu is displayed.

submenuShown

Raised after a submenu is displayed.

See Also

Types

Name Description
ContentReadyEvent

The type of the contentReady event handler's argument.

DisposingEvent

The type of the disposing event handler's argument.

InitializedEvent

The type of the initialized event handler's argument.

ItemClickEvent

The type of the itemClick event handler's argument.

ItemContextMenuEvent

The type of the itemContextMenu event handler's argument.

ItemRenderedEvent

The type of the itemRendered event handler's argument.

OptionChangedEvent

The type of the optionChanged event handler's argument.

SelectionChangedEvent

The type of the selectionChanged event handler's argument.

SelectionChangingEvent

SubmenuDirection

Specifies the direction at which the submenus are displayed.

SubmenuHiddenEvent

The type of the submenuHidden event handler's argument.

SubmenuHidingEvent

The type of the submenuHiding event handler's argument.

SubmenuShowingEvent

The type of the submenuShowing event handler's argument.

SubmenuShownEvent

The type of the submenuShown event handler's argument.