PageHeader

GitLab
Um header responsivo para as suas páginas.

Uso

O componente PageHeader exibe um cabeçalho para a sua página.

Use-o dentro do slot padrão do componente Page, antes do componente PageBody:

<template>
  <NPage>
    <NPageHeader />

    <NPageBody />
  </NPage>
</template>

Título

Use a prop title para exibir um título no cabeçalho.

PageHeader

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

Descrição

Use a prop description para exibir uma descrição no cabeçalho.

PageHeader

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

Título

Use a prop headline para exibir uma manchete no cabeçalho.

Components

PageHeader

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

Use a prop links para exibir uma lista de Button no cabeçalho.

Components

PageHeader

A responsive page header with title, description and actions.
<script setup lang="ts">
import type { ButtonProps } from '@nitro/ui'

const links = ref<ButtonProps[]>([
  {
    label: 'GitHub',
    icon: 'i-simple-icons-gitlab',
    to: 'https://gitlab.nitro.news/nitro/ui/-/tree/main/src/runtime/components/PageHeader.vue',
    target: '_blank'
  }
])
</script>

<template>
  <NPageHeader
    title="PageHeader"
    description="A responsive page header with title, description and actions."
    headline="Components"
    :links="links"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ButtonProps } from '@nitro/ui'

const links = ref<ButtonProps[]>([
  {
    label: 'GitHub',
    icon: 'i-simple-icons-gitlab',
    to: 'https://gitlab.nitro.news/nitro/ui/-/tree/main/src/runtime/components/PageHeader.vue',
    target: '_blank'
  }
])
</script>

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

Exemplos

Embora estes exemplos usem o Nuxt Content, os componentes podem ser integrados a qualquer sistema de gerenciamento de conteúdo.

Dentro de uma página

Use o componente PageHeader em uma página para exibir o cabeçalho da página:

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

definePageMeta({
  layout: 'docs'
})

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

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

<template>
  <NPage>
    <NPageHeader
      :title="page.title"
      :description="page.description"
      :headline="page.headline"
      :links="page.links"
    />

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

      <NSeparator />

      <NContentSurround :surround="surround" />
    </NPageBody>

    <template #right>
      <NContentToc :links="page.body.toc.links" />
    </template>
  </NPage>
</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 Button next to the title. { color: 'neutral', variant: 'outline' }

ui { root?: SlotClass; container?: SlotClass; wrapper?: SlotClass; headline?: SlotClass; title?: SlotClass; description?: SlotClass; links?: SlotClass; }

Slots

Slot Type
headline{}
title{}
description{}
links{}
default{}

Tema

app.config.ts
export default defineAppConfig({
  ui: {
    pageHeader: {
      slots: {
        root: 'relative border-b border-default 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-primary flex items-center gap-1.5',
        title: 'text-3xl sm:text-4xl text-pretty font-bold text-highlighted',
        description: 'text-lg text-pretty 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 '@nitro/ui/vite'

export default defineConfig({
  plugins: [
    vue(),
    ui({
      ui: {
        pageHeader: {
          slots: {
            root: 'relative border-b border-default 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-primary flex items-center gap-1.5',
            title: 'text-3xl sm:text-4xl text-pretty font-bold text-highlighted',
            description: 'text-lg text-pretty text-muted',
            links: 'flex flex-wrap items-center gap-1.5'
          },
          variants: {
            title: {
              true: {
                description: 'mt-4'
              }
            }
          }
        }
      }
    })
  ]
})

Changelog

No recent changes