--- layout: docs title: Menu edit_url: "https://github.com/nylas/N1/blob/master/src/components/menu.cjsx" ---
React component for multi-section Menus with key binding
The Menu component allows you to display a list of items. Menu takes care of several important things, ensuring that your menu is consistent with the rest of the N1 application and offers a near-native experience:
Menus are often, but not always, used in conjunction with Popover to display
a floating "popup" menu. See template-picker.cjsx for an example.
The Menu also exposes "header" and "footer" regions you can fill with arbitrary
components by providing the headerComponents and footerComponents props.
These items are nested within .header-container. and .footer-container,
and you can customize their appearance by providing CSS selectors scoped to your
component's Menu instance:
.template-picker .menu .header-container {
height: 100px;
}
React props supported by Menu:
| className |
Optional
The String class name applied to the Menu |
| itemContent |
A Function that returns a MenuItem, String, or React component for the given |
| itemKey |
A Function that returns a unique string key for the given |
| itemChecked |
A Function that returns true if the given item should be shown with a checkmark. If you don't provide an implementation for |
| items |
An Array of arbitrary objects the menu should display. |
| onSelect |
A Function called with the selected item when the user clicks an item in the menu or confirms their selection with the Enter key. |
| defaultSelectedIndex |
The index of the item first selected if there was no other previous index. Defaults to 0. Set to -1 if you want nothing selected. |
| Return Values |
|---|
Returns the currently selected item. |
Set the currently selected item. Pass null to remove the selection