Skip to main content

Header

import { Header } from '@enmovil/ui-design-system';

The application's top bar, with app and customer logos, a side-navigation toggle, a user menu and a theme toggle. It can also show page search and a notifications dropdown.

Properties​

PropertyTypeRequiredDefaultAllowed valuesDescription
classNamestringNo——Extra CSS class added to the header bar.
appLogostringNo——Image source of the app logo on the left. Nothing is shown when it is absent.
customerLogostringNo——Image source of the customer logo on the right, before the user menu. Nothing is shown when it is absent.
userDetailsuserProfileNo——The signed-in user, shown as an avatar and name that open the user menu. Without it the header shows "Welcome User" and the default avatar.
menuItemsmenuItem[]No——Entries of the user menu, listed below the theme toggle.
showThemeTogglerbooleanNofalse—Adds a Light / Dark theme toggle at the top of the user menu.
themestringNo'light''light', 'dark'Colour scheme of the header bar. Also the theme selected in the theme toggle when the header first renders.
showSearchbooleanNofalse—Shows a Search button that opens a page search over pages.
pagesPageItem[]No——Pages offered by the page search. Requires showSearch.
headerActionsheaderAction[]No[]—Icon buttons shown on the right of the header, before the customer logo.
appLogoHeightnumberNo——Height of the app logo in pixels. Without it the logo keeps its default height.
customerLogoHeightnumberNo——Height of the customer logo in pixels. Without it the logo keeps its default height.
hideToggleSideNavbooleanNofalse—Hides the side-navigation toggle (the menu icon on the left).
showNotificationsbooleanNofalse—Shows the notifications bell. The bell only appears when headerActions has at least one item.
notificationsHeaderNotificationItem[]No[]—Notifications listed in the notifications dropdown. Requires showNotifications.

userDetails​

An object (userProfile) with these fields:

FieldTypeRequiredDescription
usernamestringYesShown next to the avatar. Falls back to "Welcome User" when userDetails is absent or has no name.
emailstringYesDeclared, but not rendered by the component.
profilePicturestringNoAvatar image source. Falls back to the bundled user icon.

An array of objects (menuItem). Each object has these fields:

FieldTypeRequiredDescription
labelstringYesText of the menu entry; also its key, so labels must be unique.
iconReact.ReactNodeNoIcon shown before the label.
actionFunction() => voidNoCalled when the entry is clicked.

pages​

An array of objects (PageItem). Each object has these fields:

FieldTypeRequiredDescription
namestringYesPage title shown in the search results and matched against the search text (case-insensitive).
pathstringYesRoute the search navigates to when the page is picked. The header must be inside a React Router router.
iconReact.ReactNodeNoIcon shown before the page name in the search results.

headerActions​

An array of objects (headerAction). Each object has these fields:

FieldTypeRequiredDescription
iconReact.ReactNodeNoIcon of the action button.
onClick() => voidNoCalled when the action button is clicked.
tooltipstringNoTooltip and accessible name of the action button.
renderReact.ReactNodeNoCustom content shown in place of the icon button. When set, icon, onClick and tooltip are ignored.

notifications​

An array of objects (HeaderNotificationItem). Each object has these fields:

FieldTypeRequiredDescription
keystringYesUnique identifier, passed to the notification callbacks.
subjectstringYesTitle of the notification. Its first two letters, upper-cased, form the notification's badge.
messagestringYesBody text of the notification.
isReadbooleanNoMarks the notification as read. Unread notifications are counted on the bell.
timeDayjsNoWhen the notification arrived, a Day.js date, shown as relative time (for example "5 mins ago").
Other attributes

Header passes 272 further attributes through to the underlying element. They aren't part of the supported API and may change between releases, so use only the properties listed on this page.

Events​

NameSignatureWhen it fires
onClickAppLogo((e: MouseEvent<HTMLImageElement, MouseEvent>) => void)Fires when the app logo is clicked. When set, the logo can also be activated with Enter or Space.
onClickCustomerLogo((e: MouseEvent<HTMLImageElement, MouseEvent>) => void)Fires when the customer logo is clicked. When set, the logo can also be activated with Enter or Space.
onClickUserProfile((e: MouseEvent<HTMLDivElement, MouseEvent>) => void)Fires when the user avatar / name is clicked, alongside opening the user menu.
onToggleTheme((theme: "light" | "dark") => void)Fires with the chosen theme when the user picks Light or Dark in the theme toggle. The header also sets data-theme on the page's <body>.
onToggleSideNav(() => void)Fires when the side-navigation toggle is clicked.
onClickMarkAsRead((key: string) => void)Fires with a notification's key when its read indicator is clicked.
onClickDeleteNotification((key: string) => void)Fires with a notification's key when its close icon is clicked.
onPageSearch((text: string) => void)Fires as the page-search text changes. Requires showSearch.
onPageSelect((page: PageItem) => void)Fires when a page is picked in page search (Enter or click), before navigation. Requires showSearch.
onNotificationClick((key: string) => void)Fires when a notification row is clicked, but not its mark-as-read or delete icon. Requires showNotifications.
onNotificationsOpenChange((open: boolean) => void)Fires when the notifications dropdown opens or closes. Requires showNotifications.
onMouseEnterMouseEventHandler<HTMLElement>Fires when the pointer enters the header bar.
onMouseLeaveMouseEventHandler<HTMLElement>Fires when the pointer leaves the header bar.

Children​

Header does not accept children.

Variants​

Loading examples…

Playground​

Change the controls to see how the properties affect the component. Values the controls don't cover come from the Default example.

Loading playground…

Storybook​

Open Header in Storybook to try every story with the full set of controls.