Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
Basic components
Menu

VTEX Menu is a store component responsible for displaying a bar containing links and drop-down sub-menus.

{"base64":"  ","img":{"width":2876,"height":1636,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":1421988,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/vtex-menu-0.png"}}

Configuration

  1. Import the menu's app to your dependencies as manifest.json, for example:
"dependencies": { "vtex.menu": "2.x" }
  1. Add the vtex.menu@2.x:menu block to the store header template.

  2. To build the store's menu options, you need to configure the menu-item blocks. These can be declared in two different ways in vtex.menu@2.x:menu: as children or as props. The advantage of this latest menu-item configuration compared is that Site Editor can be used to edit the blocks.

Example:

"vtex.menu@2.x:menu#websites": { "children": [ "menu-item#shop", "menu-item#about-us" ] }, "menu-item#shop": { "props": { "id": "menu-item-shop", "type": "custom", "highlight": false, "itemProps": { "type": "internal", "href": "#", "noFollow": false, "tagTitle": "Shop", "text": "Shop" }, "iconProps": { "id": "bnd-logo", "size": 16, "viewBox": "0 0 16 16", "activeClassName": "rebel-pink", "mutedClassName": "c-action-primary" }, "iconToTheRight": true } }

Example:

"vtex.menu@2.x:menu#websites": { "props": { "items": [ { "id": "menu-item-shop", "type": "custom", "highlight": false, "itemProps": { "type": "internal", "href": "#", "noFollow": false, "tagTitle": "Shop", "text": "Shop" } }, { "id": "menu-item-about-us", "type": "custom", "highlight": false, "itemProps": { "type": "internal", "href": "/about-us", "noFollow": false, "tagTitle": "about-us", "text": "About Us" } } ] } }

You can define a submenu for a menu-item:

"menu-item#shop": { "props": { "type": "custom", "highlight": false, "itemProps": { "type": "internal", "href": "#", "noFollow": false, "tagTitle": "Shop", "text": "Shop" }, }, "blocks": ["vtex.menu@2.x:submenu#shop"] // Defining a submenu }, "vtex.menu@2.x:submenu#shop": { "children": [ "vtex.menu@2.x:menu#submenushop" ] }, "vtex.menu@2.x:menu#submenushop": { "children": [ "menu-item#shop" ] }

The Menu block has no prerequisite children. Therefore, any menu block implementation does not need to have any blocks declared within it to properly function.

The available menu-item block props are as follows:

Prop nameTypeDescriptionDefault value
typeStringMenu item type, either category or customcategory
idStringmenu item IDundefined
highlightbooleanWhether the item has highlightundefined
iconPositionStringIcon position relative to the menu item text. Either to the left or rightleft
iconPropsIconPropsIcon propsundefined
onMountBehaviorenumWhether the submenu should always be automatically displayed when its parent is hovered/clicked on (open) or not (closed).closed
itemPropsCategoryItem or CustomItemItem propsundefined
classesCustomCSSClassesUsed to override default CSS handles. To better understand how this prop works, we recommend reading about it here. Note that this is only useful if you're importing this block as a React component.undefined
  • For icons in the menu items:
Prop nameTypeDescriptionDefault value
idStringIcon IDN/A
isActivebooleanWhether the item is active or nottrue
sizenumberIcon size16
viewBoxStringIcon view box0 0 16 16
activeClassNameStringIcon classname when isActive is trueN/A
mutedClassNameStringIcon classname when isActive is falseN/A
  • For category related menu items:
Prop nameTypeDescriptionDefault value
categoryIdnumberItem category IDN/A
textStringMenu item textN/A
  • For customized items:
Prop nameTypeDescriptionDefault value
typeStringMenu item type, either internal or externalinternal
hrefStringLink to where the menu item leadsN/A
noFollowbooleanNo follow attributeN/A
tagTitleStringMenu item tagN/A
textStringMenu item textN/A

Customization

In order to apply CSS customizations on this and other blocks, follow the instructions given in the recipe on Using CSS Handles for store customization.

CSS Handle
accordionIcon--isClosed
accordionIcon--isOpen
accordionIcon
container
linkLeft
linkMiddle
linkRight
menuContainerNav
menuContainer
menuItemInnerDiv
menuItem
menuItem--isOpen
menuItem--isClosed
menuLinkDivLeft
menuLinkDivMiddle
menuLinkDivRight
menuLinkNav
renderLink
styledLinkContainer
styledLinkContent
styledLinkIcon
styledLink
submenuAccordion
submenuColumn
submenuContainer
submenuWrapper--isClosed
submenuWrapper--isOpen
submenuWrapper
submenu
Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
Was this helpful?
Yes
No
Suggest edits (Github)
Login
Minicart
Contributors
3
Photo of the contributor
Photo of the contributor
Photo of the contributor
+ 3 contributors
On this page