Our Blazor Menu component allows you to add an adaptive menu to your Blazor application. Menu items are stored in the Items collection. Each item is a DxMenuItem object that can display text, an icon, or both. Use the ItemsPosition and ItemsStretched properties to align items in the menu and stretch them.
You can specify whether Menu arranges items vertically or horizontally (the Orientation property).
For each of these Orientation options, you can also choose between the following DisplayMode options:
- Auto — adapts to the device.
- Desktop — cascading menus. Root level items appear in a horizontal or vertical panel. In horizontal orientation, second-level menus drop down. In vertical orientation, second-level menus appear to the right or left side.
- Mobile — a compact layout. In horizontal orientation, the component emulates a hamburger menu. In vertical orientation, root level items appear in the same way as in Desktop mode. The second-level menu appears within the same container (and includes a Back button).
In this demo, you can switch between display and orientation modes and review all available combinations.
The DevExpress Menu component allows you to load data from a data source to create menu items. Follow the steps below to bind the Menu to data:
- Use the Menu's Data property to specify a data source.
- Add the <DataMappings> tag to the component markup.
- In the
<DataMappings>tags, create the DxMenuDataMapping instance and map item properties to data source fields. Mappings are used to adjust the Menu's data model to the data source. For flat data, the Key and the ParentKey property is required. For hierarchical data, the Children property is required.
The Menu component supports adaptive mode. The following properties specify how the menu responds when the width of the browser window changes and there is not enough space to display all the items:
The Menu component allows you to use templates to customize the layout and appearance of the menu title and menu items.
Use the TitleTemplate property to specify the template for the menu title.
Use the following properties to specify common templates for all items:
Use the following properties to specify templates for an individual item:
Note that individual templates override common templates.
The demo above demonstrates how to use templates to create the Search and User Profile menu items.