useHeader

useHeader configures the header navigation links, defining the desktop menu items via desktopLinks with active route highlighting support. Create a file of the same name at app/composables/useHeader.ts to override this composable and fully customize the header navigation structure and link content.

Overview

useHeader() configures the desktop and mobile navigation links for the Header component.

Default implementation

It returns empty arrays by default:

composables/useHeader.ts
export function useHeader() {
  return {
    desktopLinks: computed(() => []),
    mobileLinks: computed(() => [])
  }
}

Usage examples

Overriding the default configuration

Create composables/useHeader.ts in your project to override the default configuration:

composables/useHeader.ts
export function useHeader() {
  const route = useRoute()

  return {
    desktopLinks: computed(() => [
      {
        label: 'Docs',
        to: '/docs',
        icon: 'i-lucide-book',
        active: route.path.startsWith('/docs')
      },
      {
        label: 'API',
        to: '/api',
        icon: 'i-lucide-code',
        active: route.path.startsWith('/api')
      }
    ]),

    mobileLinks: computed(() => [
      {
        label: 'Home',
        to: '/',
        icon: 'i-lucide-square-play'
      },
      {
        label: 'Docs',
        to: '/docs',
        icon: 'i-lucide-book'
      }
    ])
  }
}

Internationalization support

composables/useHeader.ts
export function useHeader() {
  const { t } = useI18n()

  return {
    desktopLinks: computed(() => [
      {
        label: t('nav.docs'),
        to: '/docs',
        icon: 'i-lucide-book'
      },
      {
        label: t('nav.api'),
        to: '/api',
        icon: 'i-lucide-code'
      }
    ]),

    mobileLinks: computed(() => [
      {
        label: t('nav.home'),
        to: '/',
        icon: 'i-lucide-square-play'
      },
      {
        label: t('nav.docs'),
        to: '/docs',
        icon: 'i-lucide-book'
      }
    ])
  }
}

API

useHeader()

Returns the Header navigation link configuration.

Return values

desktopLinks
ComputedRef<NavigationLink[]>
The desktop navigation menu items.
mobileLinks
ComputedRef<NavigationLink[]>
The mobile navigation menu items.
label
string required
The display text.
to
string required
The link URL.
icon
string
The icon class name.
active
boolean
Whether it is in the active state.
badge
string
The badge text.
children
NavigationLink[]
The submenu.

Changelog

No recent changes
Copyright © 2024 - 2026