PageHeader

A responsive page header with title, description and actions.

Usage

The PageHeader component displays a header for your page.

Use it inside the default slot of the Page component, before the PageBody component:

<template>
  <UPage>
    <UPageHeader />

    <UPageBody />
  </UPage>
</template>

Title

Use the title prop to display a title in the header.

PageHeader

<template>
  <UPageHeader title="PageHeader" />
</template>

Description

Use the description prop to display a description in the header.

PageHeader

A responsive page header with title, description and actions.
<template>
  <UPageHeader
    title="PageHeader"
    description="A responsive page header with title, description and actions."
  />
</template>

Headline

Use the headline prop to display a headline in the header.

Components

PageHeader

A responsive page header with title, description and actions.
<template>
  <UPageHeader
    title="PageHeader"
    description="A responsive page header with title, description and actions."
    headline="Components"
  />
</template>

Use the links prop to display a list of links in the header.

Components

PageHeader

A responsive page header with title, description and actions.
<template>
  <UPageHeader
    title="PageHeader"
    description="A responsive page header with title, description and actions."
    headline="Components"
    :links="[
      {
        label: 'GitHub',
        icon: 'i-simple-icons-github',
        to: 'https://github.com/nuxt/ui-pro/tree/v3/src/runtime/components/PageHeader.vue',
        target: '_blank'
      }
    ]"
  />
</template>

Examples

While these examples use Nuxt Content v3, the components can be integrated with any content management system.

Within a page

Use the PageHeader component in a page to display the header of the page:

pages/[...slug].vue
<script setup lang="ts">
const route = useRoute()

definePageMeta({ layout: 'docs' })

const { data: page } = await useAsyncData(route.path, () => {
  return queryCollection('content').path(route.path).first()
})

const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
  return queryCollectionItemSurroundings('content', route.path)
})
</script>

<template>
  <UPage>
    <UPageHeader
      :title="page.title"
      :description="page.description"
      :headline="page.headline"
      :links="page.links"
    />

    <UPageBody>
      <ContentRenderer :value="page" />

      <USeparator />

      <UContentSurround :surround="surround" />
    </UPageBody>

    <template #right>
      <UContentToc :links="page.body.toc.links" />
    </template>
  </UPage>
</template>

API

Props

Prop Default Type
as

'div'

any

The element or component this component should render as.

headline

string

title

string

description

string

links

ButtonProps[]

Display a list of Buttons next to the title. { color: 'neutral', variant: 'outline' }

ui

Partial<{ root: string; container: string; wrapper: string; headline: string; title: string; description: string; links: string; }>

Slots

Slot Type
headline

{}

title

{}

description

{}

links

{}

default

{}

Theme

app.config.ts
export default defineAppConfig({
  uiPro: {
    pageHeader: {
      slots: {
        root: 'relative border-b border-[var(--ui-border)] py-8',
        container: '',
        wrapper: 'flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4',
        headline: 'mb-2.5 text-sm font-semibold text-[var(--ui-primary)] flex items-center gap-1.5',
        title: 'text-3xl sm:text-4xl text-pretty font-bold text-[var(--ui-text-highlighted)]',
        description: 'text-lg text-pretty text-[var(--ui-text-muted)]',
        links: 'flex flex-wrap items-center gap-1.5'
      },
      variants: {
        title: {
          true: {
            description: 'mt-4'
          }
        }
      }
    }
  }
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      uiPro: {
        pageHeader: {
          slots: {
            root: 'relative border-b border-[var(--ui-border)] py-8',
            container: '',
            wrapper: 'flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4',
            headline: 'mb-2.5 text-sm font-semibold text-[var(--ui-primary)] flex items-center gap-1.5',
            title: 'text-3xl sm:text-4xl text-pretty font-bold text-[var(--ui-text-highlighted)]',
            description: 'text-lg text-pretty text-[var(--ui-text-muted)]',
            links: 'flex flex-wrap items-center gap-1.5'
          },
          variants: {
            title: {
              true: {
                description: 'mt-4'
              }
            }
          }
        }
      }
    })
  ]
})