Skip to main content

Icon Menu

Icon Menu is a combination of Icon Button and Menu List Item.

Example

Live Editor
Result
Loading...

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.

Live Editor
Result
Loading...

The component supports to customize the menu position, such as: placement, offSet.

If no specifying the placement, the placement will be auto.

Live Editor
Result
Loading...

The component supports to render items as a menu list with MenuItem with following features:

  • It allows item to be checked by adding isSelectable to IconMenu and isActive to selected MenuItem.

  • It also allows to disable an item by adding isDisabled to MenuItem.

  • Menu will be closed after clicking an item by default. To prevent this behavior, you can add closeMenuOnClick={false} to MenuItem.

Live Editor
Result
Loading...

Layouts

The component supports different padding layout: Header, Content, Action, Footer.

Live Editor
Result
Loading...

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 add closeMenuOutside={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.

Live Editor
Result
Loading...
Live Editor
Result
Loading...

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>.

Live Editor
Result
Loading...

Props

IconMenu

NameTypeDefault
iconName
Name of Icon Button
"AddValue" | "AppGrid" | "ArrowCircleLeft" | "ArrowCircleRight" | "ArrowDown" | "ArrowDownLeft" | "A...
iconSize
Size of Icon Button
"small" | "medium"
"medium"
iconKind
Kind of Icon Button
"negative" | "positive" | "warning" | "primary" | "dark" | "light"
"light"
isSelectable
allow checked state of menu item
boolean
false
itemSize
row size of menu item
"small" | "medium"
"small"
isMenuOpen
open state of menu
boolean
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
((isOpen: boolean) => void)
onClick
onClick event to overwrite the behavior of Icon Button's onClick
((isOpen: boolean) => void)
closeMenuOutside
menu is closed if clicking outside
boolean
true
width
width of menu
number
placement
placement of menu
"left" | "right" | "top" | "bottom" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end"
offSet
offset of menu
number
1
aria-label
aria-label of Icon Button
string
aria-labelledby
aria-labelledby of Icon Button
string
children
sub components
ReactNode
dataTestId
test id of components
string
"icon-menu-test-id"
customIcon
Allow to customize Icon to trigger menu: BrandIcon, AppIcon and Icon
ReactNode
data-{foo}
Data attributes can be used by testing libraries to retrieve components or assert their existence
string
* - the prop is required.

IconMenu.MenuItem

NameTypeDefault
id
id of menu item
IDtype
isActive
active (checked) state of menu item
boolean
false
isDisabled
menu item is disabled
boolean
icon
icon name of menu item
"AddValue" | "AppGrid" | "ArrowCircleLeft" | "ArrowCircleRight" | "ArrowDown" | "ArrowDownLeft" | "A...
onClick
onClick handler of menu item
((id: IDtype) => void)
closeMenuOnClick
menu is closed after clicking
boolean
true
children
sub components
ReactNode
dataTestId
test id of menu item
string
"`icon-menu-item-${id || '0'}`"
data-{foo}
Data attributes can be used by testing libraries to retrieve components or assert their existence
string
* - the prop is required.