Documentation / Layout
Header
The header bar of a site or an application: a logo, a navigation described as data (navItems), an optional search and an actions area on the right. Below the md breakpoint, the navigation, the search and the actions move into a dropdown menu opened by a burger button.
Each NavItem becomes a link (href), a button (onClick) or, if it has children, a dropdown submenu; active, badge, icon and external complete the display. The component manages the opening of the mobile menu and of the submenus itself: it is marked "use client".
The burger button’s label cannot be translated yet, and the mobile menu only appears when navItems is not empty: without navigation, the actions stay hidden on mobile.
Examples
Basic usage
A logo and three navigation entries, one of them a dropdown submenu.
import { Header, type NavItem } from "@synertech/ui";
const Logo = () => <span className="text-lg font-bold">Synertech</span>;
const navItems: NavItem[] = [
{ label: "Tableau de bord", href: "/tableau-de-bord", active: true },
{ label: "Projets", href: "/projets", badge: 3 },
{
label: "Ressources",
children: [
{ label: "Documentation", href: "/documentation" },
{ label: "Storybook", href: "https://ui.synertechweb.com/", external: true },
],
},
];
export function Basic() {
return <Header logo={<Logo />} navItems={navItems} variant="bordered" />;
}Variants
default (dark bar, light text), bordered (bottom rule), shadow (drop shadow) and transparent, to place over an image or a coloured background.
import { Header, type NavItem } from "@synertech/ui";
const Logo = () => <span className="text-lg font-bold">Synertech</span>;
const navItems: NavItem[] = [
{ label: "Tableau de bord", href: "/tableau-de-bord", active: true },
{ label: "Projets", href: "/projets", badge: 3 },
{
label: "Ressources",
children: [
{ label: "Documentation", href: "/documentation" },
{ label: "Storybook", href: "https://ui.synertechweb.com/", external: true },
],
},
];
export function Variants() {
return (
<div className="space-y-4">
<Header logo={<Logo />} navItems={navItems.slice(0, 2)} variant="default" size="sm" />
<Header logo={<Logo />} navItems={navItems.slice(0, 2)} variant="shadow" size="sm" />
<div className="bg-linear-to-r from-blue-700 to-indigo-700 text-white">
<Header logo={<Logo />} navItems={navItems.slice(0, 2)} variant="transparent" size="lg" />
</div>
</div>
);
}Search and actions
showSearch shows a field whose value is handed to onSearch on submit; actions takes the buttons on the right.
import { Avatar, Button, Header, type NavItem } from "@synertech/ui";
const Logo = () => <span className="text-lg font-bold">Synertech</span>;
const navItems: NavItem[] = [
{ label: "Tableau de bord", href: "/tableau-de-bord", active: true },
{ label: "Projets", href: "/projets", badge: 3 },
{
label: "Ressources",
children: [
{ label: "Documentation", href: "/documentation" },
{ label: "Storybook", href: "https://ui.synertechweb.com/", external: true },
],
},
];
export function WithSearchAndActions() {
return (
<Header
logo={<Logo />}
navItems={navItems.slice(0, 2)}
variant="shadow"
showSearch
searchPlaceholder="Rechercher un projet…"
onSearch={(query) => console.log("Recherche :", query)}
actions={
<>
<Button size="sm">Nouveau projet</Button>
<Avatar fallback="CM" size="sm" />
</>
}
/>
);
}Brand colours and sticky position
Colours are Tailwind classes; backgroundColor replaces the variant’s background. sticky keeps the header at the top while scrolling.
import { Header, type NavItem } from "@synertech/ui";
const Logo = () => <span className="text-lg font-bold">Synertech</span>;
const navItems: NavItem[] = [
{ label: "Tableau de bord", href: "/tableau-de-bord", active: true },
{ label: "Projets", href: "/projets", badge: 3 },
{
label: "Ressources",
children: [
{ label: "Documentation", href: "/documentation" },
{ label: "Storybook", href: "https://ui.synertechweb.com/", external: true },
],
},
];
export function BrandColors() {
return (
<Header
logo={<Logo />}
navItems={navItems}
sticky
backgroundColor="bg-emerald-700"
textColor="text-white"
navItemTextColor="text-emerald-100"
navItemHoverColor="hover:text-white"
navItemActiveColor="border-white"
/>
);
}API reference
Components
import { Header } from "@synertech/ui";Props — HeaderProps
| Prop | Type | Default | Description |
|---|---|---|---|
actions |
ReactNode |
— | |
backgroundColor |
string |
— | |
className |
string |
— | |
containerClassName |
string |
— | |
fixed |
boolean |
false |
|
hoverColor |
string |
— | |
linkComponent |
UILinkComponent |
— | The link of the application's router ( |
logo |
ReactNode |
— | |
logoHref |
string |
"/" |
Where the logo leads. Any other address than an |
menuLabel |
string |
— | Accessible name of the button opening the menu on a small screen. Defaults to the |
navItemActiveColor |
string |
— | |
navItemBgHover |
string |
— | |
navItemHoverColor |
string |
— | |
navItems |
NavItem[] |
[] |
|
navItemTextColor |
string |
— | |
onLogoClick |
(event: MouseEvent<HTMLAnchorElement>) => void |
— | Called on a click on the logo, with its event. |
onSearch |
(query: string) => void |
— | |
rightContent |
ReactNode |
— | |
searchPlaceholder |
string |
— | |
showSearch |
boolean |
false |
|
size |
"sm" | "md" | "lg" |
"md" |
|
sticky |
boolean |
false |
|
textColor |
string |
— | |
variant |
"default" | "transparent" | "bordered" | "shadow" |
"default" |
Types
NavItem
Interfaceinterface NavItem| Field | Type | Default | Description |
|---|---|---|---|
label• |
string |
— | |
active |
boolean |
— | |
badge |
string | number |
— | Shown beside the label, |
children |
NavItem[] |
— | |
external |
boolean |
— | Opens in a new tab, always as an |
href |
string |
— | Where it leads. An |
icon |
ReactNode |
— | |
onClick |
(event: MouseEvent<HTMLElement>) => void |
— | Called on a click, with its event. With an |