Documentation / Mise en page
Header
La barre d’en-tête d’un site ou d’une application : un logo, une navigation décrite en données (navItems), une recherche facultative et une zone d’actions à droite. Sous le point de rupture md, la navigation, la recherche et les actions passent dans un menu déroulant ouvert par un bouton burger.
Chaque NavItem devient un lien (href), un bouton (onClick) ou, s’il a des children, un sous-menu déroulant ; active, badge, icon et external complètent l’affichage. Le composant gère lui-même l’ouverture du menu mobile et des sous-menus : il est marqué "use client".
Le libellé du bouton burger n’est pas encore traduisible, et le menu mobile n’apparaît que si navItems n’est pas vide : sans navigation, les actions restent masquées sur mobile.
Exemples
Utilisation de base
Un logo et trois entrées de navigation, dont un sous-menu déroulant.
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" />;
}Variantes
default (barre sombre, texte clair), bordered (filet inférieur), shadow (ombre portée) et transparent, à poser sur une image ou un fond coloré.
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>
);
}Recherche et actions
showSearch affiche un champ dont la valeur est remise à onSearch à la validation ; actions reçoit les boutons de droite.
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" />
</>
}
/>
);
}Couleurs de marque et position collante
Les couleurs sont des classes Tailwind ; backgroundColor remplace le fond de la variante. sticky garde l’en-tête en haut au défilement.
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"
/>
);
}Référence d’API
Composants
import { Header } from "@synertech/ui";Props — HeaderProps
| Prop | Type | Défaut | Description |
|---|---|---|---|
actions |
ReactNode |
— | |
backgroundColor |
string |
— | |
className |
string |
— | |
containerClassName |
string |
— | |
fixed |
boolean |
false |
|
hoverColor |
string |
— | |
linkComponent |
UILinkComponent |
— | Le lien du routeur de l’application ( |
logo |
ReactNode |
— | |
logoHref |
string |
"/" |
Où mène le logo. Toute autre adresse qu’une adresse |
menuLabel |
string |
— | Nom accessible du bouton qui ouvre le menu sur petit écran. Par défaut, le libellé |
navItemActiveColor |
string |
— | |
navItemBgHover |
string |
— | |
navItemHoverColor |
string |
— | |
navItems |
NavItem[] |
[] |
|
navItemTextColor |
string |
— | |
onLogoClick |
(event: MouseEvent<HTMLAnchorElement>) => void |
— | Appelée au clic sur le logo, avec son événement. |
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| Champ | Type | Défaut | Description |
|---|---|---|---|
label• |
string |
— | |
active |
boolean |
— | |
badge |
string | number |
— | Affichée à côté du libellé, |
children |
NavItem[] |
— | |
external |
boolean |
— | S’ouvre dans un nouvel onglet, toujours en |
href |
string |
— | Où il mène. Une adresse |
icon |
ReactNode |
— | |
onClick |
(event: MouseEvent<HTMLElement>) => void |
— | Appelée au clic, avec son événement. Avec un |