Synertech Web/ui v0.57.5 Site Storybook

Documentation / Layout

Header

Client@synertech/uiOpen in Storybook

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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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"
    />
  );
}

Navigation through handlers

In a single-page application, onClick replaces href: the entry becomes a <button> and the application’s router takes over.

Open in a tab
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 ClientNavigation() {
  const go = (path: string) => () => console.log("Navigation vers", path);

  return (
    <Header
      logo={<Logo />}
      variant="bordered"
      navItems={[
        { label: "Clients", onClick: go("/clients") },
        { label: "Factures", onClick: go("/factures") },
      ]}
    />
  );
}

API reference

Components

ComponentClient
import { Header } from "@synertech/ui";

Props — HeaderProps

PropTypeDefaultDescription
actions ReactNode —
backgroundColor string —
className string —
containerClassName string —
fixed boolean false
hoverColor string —
linkComponent UILinkComponent —

The link of the application's router (next/link, the Link of next-intl), rendered by the logo and by every item that has an href and is not external. Defaults to the linkComponent of the nearest UILabelsProvider; without either, a click loads the whole page again.

logoHref string "/"

Where the logo leads. Any other address than an http:, https:, mailto:, tel: or relative one (javascript:…) leaves the logo without a link.

menuLabel string —

Accessible name of the button opening the menu on a small screen. Defaults to the headerToggleMenu label.

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

Interface
interface NavItem
FieldTypeDefaultDescription