~/designkit/header/

Header

The same header on every site. An app decides its links and languages; everything else is fixed.

~/designkit/header.preview

Playground

A real page in a frame, with the real header. Change its width to see the menu fold at 1120px, scroll inside it to see the bar and the frosted state.

Width
Links

~/designkit/header.props

PerApp

What changes per app, and nothing else:

  • The links, numbered 01., 02., … in order.
  • Which link is current.
  • The language links: the same page in English and Dutch.
  • The language of the labels.
  • Whether the Ctrl K button shows: only when the app has a command menu.

What stays exactly the same:

The <JO/> logo linking to joeyoosenbrug.nl, the height of 60px, the maximum width of 1360px, the pill language switch, the theme button, the burger below 1120px, the gradient progress bar, the frosted background once scrolled, every colour, size and animation.

~/designkit/header.js

Behaviour

One script, header.js, does all of it for every framework.

FeatureHow it works
Progress barA 2px teal to purple gradient along the bottom edge, scaled to the scroll position.
Frosted stateAfter 12px of scroll: --bg at 78%, blur(16px) and a bottom border.
Active linkaria-current on the link. Links to #sections on the same page are tracked while scrolling; above the first section, none is marked.
Mobile menuBelow 1120px the links move into a dropdown card. It closes on a link click and on Escape.
Number prefixes01. shows above 1480px and in the mobile menu. In between it is hidden to save room.
ThemeA sun in dark mode, a moon in light mode. Saved in a jo-theme cookie on .joeyoosenbrug.nl, shared by every subdomain, plus localStorage.
Ctrl KHidden unless onSearch is passed. Then the button shows and Ctrl/Cmd+K calls it.

~/designkit/header.usage

Usage

The same header in four forms. Pick yours.

A wrapper of about fifteen lines hands your app’s state to the kit’s header. Wrap it in {#key page.url.pathname} if the links or labels change between pages.

src/lib/components/Header.svelte
<script lang="ts">
  import { page } from '$app/state';
  import { Header, headerLabels } from '@joeykwispel/design-kit/svelte';

  // 'en' | 'nl', from wherever your app keeps it
  let { locale } = $props();

  const links = $derived([
    { label: 'Play', href: '/play/', current: page.url.pathname === '/play/' },
    { label: 'Scores', href: '/scores/', current: page.url.pathname === '/scores/' }
  ]);
  const languages = $derived([
    { code: 'en', href: '/', current: locale === 'en' },
    { code: 'nl', href: '/nl/', current: locale === 'nl' }
  ]);
</script>

<Header {links} {languages} labels={headerLabels[locale]} />

~/designkit/header.d.ts

Props

The Svelte and React headers take the same props.

PropTypeNotes
linksHeaderLink[]Leave it empty and the menu and burger are not rendered.
languagesHeaderLanguage[]The same page in each language, not the home page.
labelsHeaderLabelsheaderLabels.en or headerLabels.nl from the package.
homeHrefstringWhere the logo goes. The portfolio, unless you have a very good reason.
onSearch() => voidShows the Ctrl K button and binds Ctrl/Cmd+K.
onLanguage(code: string) => voidSvelte only. Called with the language code on a click, for remembering the choice.
skipbooleanSvelte only, on by default. Renders the "skip to content" link before the header.
toolsSnippetThe app’s own controls, such as a sign-in button, placed before the language switch. In React: children.

A command menu

any framework
import { initJoHeader } from '@joeykwispel/design-kit/header';

// Passing onSearch shows the Ctrl K button and binds Ctrl/Cmd+K.
const destroy = initJoHeader(document.querySelector('.jo-nav'), {
  onSearch: () => openCommandMenu()
});