Menu
A menu displays a list of choices on a temporary surface. It appears when the user interacts with a button, or other control.
Introduction
Menus are implemented using a collection of related components:
- Menu: The container/surface of the menu.
- Menu Item: An option for users to select from the menu.
- Menu List (optional): Alternative composable container for Menu Items for details.
Basic Menu
A basic menu opens over the anchor element by default. When close to a screen edge, a basic menu vertically realigns to make sure that all menu items are completely visible.
You should configure the component so that selecting an option immediately confirms it and closes the menu, as shown in the demo below.
Preview
Usage
import { Menu, MenuItem } from 'archi-ui'
<Menu open={true}>
<MenuItem divider>Item 1</MenuItem>
<MenuItem divider>Item 2</MenuItem>
<MenuItem divider>Item 3</MenuItem>
<MenuItem divider>Item 4</MenuItem>
</Menu>
Icon menu
Preview
- CutClt X
- CopyClt C
- PasteClt V
Dense menu
For the menu taht has long list and long text, you can use the dense
prop in MenuItem
component to reduce the padding and text size.
Preview
- View
- Short by
- Refresh
- New
- Display setting
- Personalize
- Open in terminal
- Show more options...
Selected menu
If used for item selection, when opened, simple menus places the initial focus on the selected menu item. The currently selected menu item is set using the selected prop from MenuItem.
Preview
My account
positioned menu
You can display the menu on top of the anchor.
Preview
Account menu
Menu
content can be mixed with other components like Avatar
.
Preview
Home
About
Task
Max height menu
If the height of a menu prevents all menu items from being displayed, the menu can scroll internally.
Preview
Menu API
API reference docs for the React Menu component.
Props
Name | Type | Default | Description |
---|---|---|---|
children | node | - | Menu contents, normally MenuItem . |
className | string | - | Override or extend the styles applied to the component |
open | bool | - | If true , the component is shown. |
anchorEl | HTML element | func | - | An HTML element, or a function that returns one. It’s used to set the position of the menu. |
onClose | func | - | Callback fired when the component is requests to be closed. Signature: function() => void . |
disableEscapeKeyDown | bool | false | If true , hitting escape will not fire the onClose callback. |
onBackdropClick | func | - | A function is triggred if provided when backdrop is been clicked. |
BackdropProps | object | - | Props applied to the Backdrop element. |
hideBackdrop | bool | false | If true , the backdrop is not rendered. |
scrollLock | bool | true | Disable the scroll lock behavior. |
anchorOrigin | { horizontal: 'center'|'left'|'right', vertical: 'center'|'bottom'|'top' } | { vertical:'bottom', horizontal:'left' } | This is the point on the anchor where the Menu’s anchorEl wil attach to.Options: vertical: [top, center, bottom], horizontal: [left, center, right]. |
transformOrigin | { horizontal: 'center'|'left'|'right', vertical: 'center'|'bottom'|'top' } | { vertical:'top', horizontal:'left' } | This is the point on the Menu which will attach to the anchor’s origin. Options: vertical: [top, center, bottom], horizontal: [left, center, right]. |