Expanded MenuItem Icon
The expandedMenuItemIcon
prop allows customization of the icon for expanded submenu items.
Props
type RenderExpandedMenuItemIcon = {
icon:
| ReactElement
| ((params: { level?: number; active?: boolean; disabled?: boolean }) => ReactElement | null)
| null
level?: number
}
type renderExpandedMenuItemIcon?: RenderExpandedMenuItemIcon
Basic
This example demonstrates using a ReactElement as the icon.
Example
/horizontal-menu/menu/expanded-menu-item-icon/basic
Source Code
// Third-party Imports
import classnames from 'classnames'
// Component Imports
import HorizontalNav, { Menu, MenuItem, SubMenu } from '@menu/horizontal-menu'
// Style Imports
import styles from '../../styles.module.css'
const ExpandMenuItemIcon = () => {
return (
<div className={classnames('flex items-center plb-2.5 pli-6 w-full', styles.customStyles)}>
<HorizontalNav>
<Menu>
<SubMenu label='Dashboards'>
<MenuItem>Analytics</MenuItem>
<MenuItem disabled>eCommerce</MenuItem>
</SubMenu>
<MenuItem>Calendar</MenuItem>
<MenuItem>FAQ</MenuItem>
<SubMenu label='Menu Level'>
<MenuItem>Menu Level 2.1</MenuItem>
<SubMenu label='Menu Level 2.2'>
<MenuItem>Menu Level 3.1</MenuItem>
<SubMenu label='Menu Level 3.2'>
<MenuItem>Menu Level 4.1</MenuItem>
</SubMenu>
</SubMenu>
</SubMenu>
<MenuItem>Documentation</MenuItem>
</Menu>
</HorizontalNav>
</div>
)
}
export default ExpandMenuItemIcon
Icon With Level
This example shows using a ReactElement as the icon and passing the level parameter.
/horizontal-menu/menu/expanded-menu-item-icon/icon-with-level
Source Code
// Third-party Imports
import classnames from 'classnames'
// Component Imports
import HorizontalNav, { Menu, MenuItem, SubMenu } from '@menu/horizontal-menu'
// Style Imports
import styles from '../../styles.module.css'
const ExpandMenuItemIcon = () => {
return (
<div className={classnames('flex items-center plb-2.5 pli-6 w-full', styles.customStyles)}>
<HorizontalNav>
<Menu renderExpandedMenuItemIcon={{ icon: <>🔥</>, level: 2 }}>
<SubMenu label='Dashboards'>
<MenuItem>Analytics</MenuItem>
<MenuItem disabled>eCommerce</MenuItem>
</SubMenu>
<MenuItem>Calendar</MenuItem>
<MenuItem>FAQ</MenuItem>
<SubMenu label='Menu Level'>
<MenuItem>Menu Level 2.1</MenuItem>
<SubMenu label='Menu Level 2.2'>
<MenuItem>Menu Level 3.1</MenuItem>
<SubMenu label='Menu Level 3.2'>
<MenuItem>Menu Level 4.1</MenuItem>
</SubMenu>
</SubMenu>
</SubMenu>
<MenuItem>Documentation</MenuItem>
</Menu>
</HorizontalNav>
</div>
)
}
export default ExpandMenuItemIcon
Icon With Params
This example uses a function as the icon
/horizontal-menu/menu/expanded-menu-item-icon/icon-with-param
Source Code
'use client'
// Third-party Imports
import classnames from 'classnames'
// Component Imports
import HorizontalNav, { Menu, MenuItem, SubMenu } from '@menu/horizontal-menu'
// Style Imports
import styles from '../../styles.module.css'
const ExpandMenuItemIcon = () => {
return (
<div className={classnames('flex items-center plb-2.5 pli-6 w-full', styles.customStyles)}>
<HorizontalNav>
<Menu renderExpandedMenuItemIcon={{ icon: ({ disabled }) => (disabled ? null : <>🔥</>) }}>
<SubMenu label='Dashboards'>
<MenuItem>Analytics</MenuItem>
<MenuItem disabled>eCommerce</MenuItem>
</SubMenu>
<MenuItem>Calendar</MenuItem>
<MenuItem>FAQ</MenuItem>
<SubMenu label='Menu Level'>
<MenuItem>Menu Level 2.1</MenuItem>
<SubMenu label='Menu Level 2.2'>
<MenuItem>Menu Level 3.1</MenuItem>
<SubMenu label='Menu Level 3.2'>
<MenuItem>Menu Level 4.1</MenuItem>
</SubMenu>
</SubMenu>
</SubMenu>
<MenuItem>Documentation</MenuItem>
</Menu>
</HorizontalNav>
</div>
)
}
export default ExpandMenuItemIcon
Icon WIth Param Level
This example utilizes a function as the icon and passes the level parameter.
/horizontal-menu/menu/expanded-menu-item-icon/icon-with-param-level
Source Code
'use client'
// Third-party Imports
import classnames from 'classnames'
// Component Imports
import HorizontalNav, { Menu, MenuItem, SubMenu } from '@menu/horizontal-menu'
// Style Imports
import styles from '../../styles.module.css'
const ExpandMenuItemIcon = () => {
return (
<div className={classnames('flex items-center plb-2.5 pli-6 w-full', styles.customStyles)}>
<HorizontalNav>
<Menu
renderExpandedMenuItemIcon={{
icon: ({ disabled, level }) => (disabled ? null : level === 1 ? <>#</> : <>*</>),
level: 2
}}
>
<SubMenu label='Dashboards'>
<MenuItem>Analytics</MenuItem>
<MenuItem disabled>eCommerce</MenuItem>
</SubMenu>
<MenuItem>Calendar</MenuItem>
<MenuItem>FAQ</MenuItem>
<SubMenu label='Menu Level'>
<MenuItem>Menu Level 2.1</MenuItem>
<SubMenu label='Menu Level 2.2'>
<MenuItem>Menu Level 3.1</MenuItem>
<SubMenu label='Menu Level 3.2'>
<MenuItem>Menu Level 4.1</MenuItem>
</SubMenu>
</SubMenu>
</SubMenu>
<MenuItem>Documentation</MenuItem>
</Menu>
</HorizontalNav>
</div>
)
}
export default ExpandMenuItemIcon