Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
VTEX IO Apps
Header
Official extension
Version: 2.29.2
Latest version: 2.29.2

Source code

The Header app displays a navigation bar at the top of your store pages. It serves as the central hub for essential navigation elements, such as your store logo, the minicart, user login, and the search bar.

{"base64":"  ","img":{"width":2854,"height":1578,"type":"png","mime":"image/png","wUnits":"px","hUnits":"px","length":1340793,"url":"https://user-images.githubusercontent.com/52087100/74090325-b6235d00-4a88-11ea-8227-317f93204d8f.png"}}

Installation

  1. Add the store-header app to your theme's dependencies in the manifest.json file:

_10
dependencies: {
_10
"vtex.store-header": "2.x"
_10
}

You can now use all the blocks exported by the store-header app. The following table lists the available blocks:

Block nameDescription
header-layout.desktop
{"base64":"  ","img":{"width":69,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/-Mandatory-red"}}
Defines the Header layout for desktop devices through header-row blocks.
header-layout.mobileDefines the Header layout for mobile devices through header-row blocks.
header-row
{"base64":"  ","img":{"width":69,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/-Mandatory-red"}}
Create Header lines according to your store needs.
header-borderAdds a 1px margin to a Header row.
header-force-centerCentralizes its children blocks in a Header row.
header-spacerAdds spacing between blocks throughout a Header row.

Configuration

  1. Declare the header-layout.desktop and header-layout.mobile blocks in your header.jsonc file. This allows you to define different header structures for desktop and mobile devices.

_10
{
_10
"header": {
_10
"blocks": [
_10
"header-layout.desktop",
_10
"header-layout.mobile"
_10
]
_10
},

The Header is a default store interface element defined in the interfaces.json file, so you don't need to declare it in every template. Store Framework automatically applies your configuration across all store pages. To customize the header for specific pages, see the Advanced configuration section.

  1. In your header.jsonc file, define header-row blocks inside header-layout.desktop and header-layout.mobile. The number of rows depends on your store design.

_15
{
_15
"header": {
_15
"blocks": [
_15
"header-layout.desktop",
_15
"header-layout.mobile"
_15
]
_15
},
_15
"header-layout.desktop": {
_15
"children": [
_15
"header-row#1-desktop",
_15
"header-row#2-desktop",
_15
"header-row#3-desktop",
_15
"header-row#4-desktop"
_15
]
_15
},

The example above uses four rows for the desktop header. This setup allows replicating the header to include telemarketing functionalities (when activated), notifications, page links, and other blocks, such as a logo and menu.

  1. Configure each header-row by adding props and declaring the desired blocks as children. The most commonly used blocks are Logo, Minicart, and Menu.

In the example below, we'll add a Telemarketing bar to the first row:


_10
"header-row#1-desktop": {
_10
"children": [
_10
"telemarketing"
_10
],
_10
"props": {
_10
"fullWidth": true
_10
}
_10
},

  • header-row props:
Prop nameTypeDescriptionDefault value
zIndexNumberControls the vertical stacking order of elements for overlapping.0
stickyBooleanDetermines if the header row remains fixed at the top of the screen during scroll (true) or not (false).false
fullWidthBooleanDetermines if the header row should span the full width of the screen.true
invertedBooleanIf true, the row uses the inverted base color defined in styles.json.false

⚠️ Repeat this process for all header-row blocks in both header-layout.desktop and header-layout.mobile, configuring each block with the necessary props.

Layout customization blocks

You can use the header-border, header-force-center, and header-spacer blocks as children of header-row to customize your header layout.

  • header-border

Adds a 1px margin to a header row.


_14
"header-row#2-desktop": {
_14
"children": [
_14
"header-border",
_14
"notification.bar#home"
_14
],
_14
"props": {
_14
"fullWidth": "true"
_14
}
_14
},
_14
"notification.bar#home": {
_14
"props": {
_14
"content": "SELECTED ITEMS ON SALE! CHECK IT OUT!"
_14
}
_14
},

  • header-force-center

Centralizes its child blocks within a header row.


_24
"header-row#4-desktop": {
_24
"props": {
_24
"blockClass": "main-header",
_24
"horizontalAlign": "center",
_24
"verticalAlign": "center",
_24
"preventHorizontalStretch": true,
_24
"preventVerticalStretch": true,
_24
"fullWidth": true
_24
},
_24
"children": ["header-force-center"]
_24
},
_24
"header-force-center": {
_24
"children":[
_24
"logo#desktop"
_24
]
_24
},
_24
"logo#desktop": {
_24
"props": {
_24
"title": "Logo",
_24
"href": "/",
_24
"url": "https://storecomponents.vteximg.com.br/arquivos/store-theme-logo.png",
_24
"width": "180"
_24
}
_24
},

  • header-spacer:

Adds a flexible space between blocks in a header row. Blocks declared before header-spacer are pushed to the left, and blocks declared after are pushed to the right.


_11
"header-row#3-desktop": {
_11
"children": [
_11
"vtex.menu@2.x:menu#websites",
_11
"header-spacer",
_11
"vtex.menu@2.x:menu#institutional"
_11
],
_11
"props": {
_11
"blockClass": "menu-link",
_11
"inverted": "true"
_11
}
_11
},

Advanced configuration

By default, the header configuration is applied to all store templates. To override this behavior and apply custom configurations to different templates, you can modify the interfaces.json file.

For detailed instructions, see the guide Customizing the Header and Footer blocks by page.

Customization

To apply CSS customizations to these and other blocks, follow the instructions in Using CSS Handles for store customization.

CSS Handles
container
leanMode
topMenuContainer
topMenuLogo
topMenuSearchBar
topMenuIcons
topMenuCollapsible
forceCenter
forceCenterInnerContainer
headerBorder
headerSpacer
headerStickyRow
headerRowContentContainer
See also
VTEX App Store
VTEX IO Apps
Was this helpful?