-
Data Grid
- Overview
-
Data Binding
-
Paging and Scrolling
-
Editing
-
Grouping
-
Filtering and Sorting
- Focused Row
-
Row Drag & Drop
-
Selection
-
Columns
- State Persistence
-
Appearance
-
Templates
-
Data Summaries
-
Master-Detail
-
Export to PDF
-
Export to Excel
-
Adaptability
- Keyboard Navigation
-
Pivot Grid
- Overview
-
Data Binding
-
Field Chooser
-
Features
-
Export to Excel
-
Tree List
- Overview
-
Data Binding
- Sorting
- Paging
-
Editing
- Node Drag & Drop
- Focused Row
-
Selection
-
Filtering
-
Column Customization
- State Persistence
- Adaptability
- Keyboard Navigation
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Features
- Virtual Scrolling
-
Grouping
-
Customization
- Adaptability
-
Html Editor
-
Chat
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
Charts
- Overview
-
Data Binding
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Line Charts
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
-
Sparkline Charts
-
Tree Map
-
Funnel and Pyramid Charts
- Sankey Chart
-
Combinations
-
More Features
-
Export
-
Selection
-
Tooltips
-
Zooming
-
-
Gantt
- Overview
-
Data
-
UI Customization
- Strip Lines
- Export to PDF
- Sorting
-
Filtering
-
Gauges
- Overview
-
Data Binding
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Navigation
- Overview
- Accordion
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
- Pagination
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
- Resizable
-
-
Editors
- Overview
- Autocomplete
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Drop Down Box
-
Number Box
-
Select Box
- Switch
-
Tag Box
- Text Area
- Text Box
- Validation
- Custom Text Editor Buttons
- Right-to-Left Support
- Editor Appearance Variants
-
Forms and Multi-Purpose
- Overview
- Button Group
- Field Set
-
Filter Builder
-
Form
- Radio Group
-
Range Selector
- Numeric Scale (Lightweight)
- Numeric Scale
- Date-Time Scale (Lightweight)
- Date-Time Scale
- Logarithmic Scale
- Discrete scale
- Custom Formatting
- Use Range Selection for Calculation
- Use Range Selection for Filtering
- Image on Background
- Chart on Background
- Customized Chart on Background
- Chart on Background with Series Template
- Range Slider
- Slider
-
Sortable
-
File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Actions and Lists
- Overview
-
Action Sheet
-
Button
- Floating Action Button
- Drop Down Button
-
Context Menu
-
List
-
Lookup
-
Maps
- Overview
-
Map
-
Vector Map
-
Dialogs and Notifications
-
Localization
React Menu - Overview
Populate Menu with Data and Configure the Access to It
You can display Menu items from the items array or a dataSource. This demo contains an example of a data structure. If you use a dataSource, specify the displayExpr property.
To access the clicked item, use the onItemClick event handler function.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
import React, { useCallback, useState } from 'react';
import Menu, { MenuTypes } from 'devextreme-react/menu';
import SelectBox, { SelectBoxTypes } from 'devextreme-react/select-box';
import CheckBox, { CheckBoxTypes } from 'devextreme-react/check-box';
import service, { ProductItemType } from './data.ts';
const orientations = ['horizontal', 'vertical'];
const orientationLabel = { 'aria-label': 'Orientation' };
const showSubmenuModeLabel = { 'aria-label': 'Show Submenu Mode' };
const products = service.getProducts();
interface showSubmenuModesType {
name: MenuTypes.SubmenuShowMode,
delay: {
show: number,
hide: number
}
}
const showSubmenuModes: showSubmenuModesType[] = [
{
name: 'onHover',
delay: { show: 0, hide: 500 },
},
{
name: 'onClick',
delay: { show: 0, hide: 300 },
},
];
const App = () => {
const [showFirstSubmenuModes, setShowFirstSubmenuModes] = useState(showSubmenuModes[1]);
const [orientation, setOrientation] = useState<MenuTypes.Orientation>('horizontal');
const [hideSubmenuOnMouseLeave, setHideSubmenuOnMouseLeave] = useState(false);
const [currentProduct, setCurrentProduct] = useState(null);
const itemClick = useCallback((e: MenuTypes.ItemClickEvent & { itemData: ProductItemType }) => {
if (e.itemData.price) {
setCurrentProduct(e.itemData);
}
}, [setCurrentProduct]);
const showSubmenuModeChanged = useCallback((e: SelectBoxTypes.ValueChangedEvent) => {
setShowFirstSubmenuModes(e.value);
}, [setShowFirstSubmenuModes]);
const orientationChanged = useCallback((e: SelectBoxTypes.ValueChangedEvent) => {
setOrientation(e.value);
}, [setOrientation]);
const hideSubmenuOnMouseLeaveChanged = useCallback((e: CheckBoxTypes.ValueChangedEvent) => {
setHideSubmenuOnMouseLeave(e.value);
}, [setHideSubmenuOnMouseLeave]);
return (
<div className="form">
<div>
<div className="label">Catalog:</div>
<Menu
dataSource={products}
displayExpr="name"
showFirstSubmenuMode={showFirstSubmenuModes}
orientation={orientation}
hideSubmenuOnMouseLeave={hideSubmenuOnMouseLeave}
onItemClick={itemClick}
/>
{currentProduct && (
<div id="product-details">
<img src={currentProduct.icon} />
<div className="name">{currentProduct.name}</div>
<div className="price">{`$${currentProduct.price}`}</div>
</div>
)}
</div>
<div className="options">
<div className="caption">Options</div>
<div className="option">
<div>Show First Submenu Mode</div>
<SelectBox
items={showSubmenuModes}
displayExpr="name"
inputAttr={showSubmenuModeLabel}
value={showFirstSubmenuModes}
onValueChanged={showSubmenuModeChanged}
/>
</div>
<div className="option">
<div>Orientation</div>
<SelectBox
items={orientations}
inputAttr={orientationLabel}
value={orientation}
onValueChanged={orientationChanged}
/>
</div>
<div className="option">
<CheckBox
text="Hide Submenu on Mouse Leave"
value={hideSubmenuOnMouseLeave}
onValueChanged={hideSubmenuOnMouseLeaveChanged}
/>
</div>
</div>
</div>
);
};
export default App;
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
xxxxxxxxxx
Configure the Menu
Use the orientation property to specify whether the Menu has horizontal or vertical orientation. Use the animation property to specify the type, delay, duration, and other options of show and hide menu actions.
Configure the Submenus
Clicking or a hovering a Menu item opens a drop-down menu that can contain several submenus. To specify the drop-down menu mode ("onClick" or "onHover"), use the showSubmenuMode property. If you need only to specify the first level of drop-down menus, use the showFirstSubmenuMode property.
If you want to hide the submenu when the mouse pointer leaves it, set the hideSubmenuOnMouseLeave property to true.
Customize Item Appearance
You can define specific fields in the item data objects to change the appearance of an item. For example, use the icon property to supply items with icons. Define an itemTemplate to customize item appearance.