Icon Menu
Icon Menu is a combination of Icon Button and Menu List Item.
Example
Sub Component
<IconMenu />
has 5 sub components:
<IconMenu.MenuItem />
supports list menu items<IconMenu.Header />
supports layout, e.g: search box, title.<IconMenu.Content />
supports layout.<IconMenu.Action />
supports layout.<IconMenu.Footer />
supports layout.
Variant
Icon Button
The component supports to customize the icon button, such as: iconName
, iconSize
, iconKind
.
Menu Position
The component supports to customize the menu position, such as: placement
, offSet
.
If no specifying the placement
, the placement
will be auto.
Menu Items
The component supports to render items as a menu list with MenuItem
with following features:
It allows item to be checked by adding
isSelectable
toIconMenu
andisActive
to selectedMenuItem
.It also allows to disable an item by adding
isDisabled
toMenuItem
.Menu will be closed after clicking an item by default. To prevent this behavior, you can add
closeMenuOnClick={false}
toMenuItem
.
Layouts
The component supports different padding layout: Header
, Content
, Action
, Footer
.
Open State
The component supports to manage the open state with several props
isMenuOpen
to set open state of menu.onToggle
to inform the open state of menu after clicking on icon button or menu item.closeMenuOutside
to close the menu when clicking outside. By default, menu is closed when clicking outside. To prevent this behavior, you can addcloseMenuOutside={false}
to component.onClick
to overwrite the onClick event of Icon Button. Please be careful if using this prop, you should handle the open state by yourself.
warning
onToggle
doesn't work along with closeMenuOutside
, closeMenuOnClick
and onClick
.
Custom Icon Element
The component is using IconButton to trigger the menu by default. But you can customise the icon with other Icon Components such as: BrandIcon, AppIcon, and Icon by adding customIconElement
to <IconMenu>
.
Props
IconMenu
Name | Type | Default |
---|---|---|
iconName Name of Icon Button | "AddValue" | "AppGrid" | "ArrowCircleLeft" | "ArrowCircleRight" | "ArrowDown" | "ArrowDownLeft" | "A... | — |
iconSize Size of Icon Button |
| "medium" |
iconKind Kind of Icon Button |
| "light" |
isSelectable allow checked state of menu item |
| false |
itemSize row size of menu item |
| "small" |
isMenuOpen open state of menu |
| — |
onToggle a callback to inform the open state of menu after clicking on icon button or menu item. onToggle doesn't work along with closeMenuOutside, closeMenuOnClick and onClick |
| — |
onClick onClick event to overwrite the behavior of Icon Button's onClick |
| — |
closeMenuOutside menu is closed if clicking outside |
| true |
width width of menu |
| — |
placement placement of menu |
| — |
offSet offset of menu |
| 1 |
aria-label aria-label of Icon Button |
| — |
aria-labelledby aria-labelledby of Icon Button |
| — |
children sub components |
| — |
dataTestId test id of components |
| "icon-menu-test-id" |
customIcon Allow to customize Icon to trigger menu: BrandIcon, AppIcon and Icon |
| — |
data-{foo} Data attributes can be used by testing libraries to retrieve components or assert their existence |
| — |
* - the prop is required. |
IconMenu.MenuItem
Name | Type | Default |
---|---|---|
id id of menu item |
| — |
isActive active (checked) state of menu item |
| false |
isDisabled menu item is disabled |
| — |
icon icon name of menu item | "AddValue" | "AppGrid" | "ArrowCircleLeft" | "ArrowCircleRight" | "ArrowDown" | "ArrowDownLeft" | "A... | — |
onClick onClick handler of menu item |
| — |
closeMenuOnClick menu is closed after clicking |
| true |
children sub components |
| — |
dataTestId test id of menu item |
| "`icon-menu-item-${id || '0'}`" |
data-{foo} Data attributes can be used by testing libraries to retrieve components or assert their existence |
| — |
* - the prop is required. |