본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

PageHeader 페이지 헤더

원문 보기 위키 갱신

페이지를 위한 반응형 헤더 컴포넌트예요. 제목·설명·헤드라인·링크 버튼을 표시할 수 있으며, Page 컴포넌트의 기본 슬롯 안에서 PageBody 앞에 배치해요.

출처: Nuxt UI

본문

페이지를 위한 반응형 헤더예요.

사용법 (Usage)

PageHeader 컴포넌트는 페이지의 헤더를 표시해요.

Page 컴포넌트의 기본 슬롯 안에서 PageBody 컴포넌트 앞에 사용하세요.

<template>
  <UPage>
    <UPageHeader />

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

Title

title prop을 이용해 헤더에 제목을 표시할 수 있어요.

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

Description

description prop을 이용해 헤더에 설명을 표시할 수 있어요.

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

Headline

headline prop을 이용해 헤더에 헤드라인을 표시할 수 있어요.

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

links prop을 이용해 헤더에 Button 목록을 표시할 수 있어요.

<script setup lang="ts">
import type { ButtonProps } from '@nuxt/ui'

const links = ref<ButtonProps[]>([
  {
    label: "GitHub",
    icon: "i-simple-icons-github",
    to: "https://github.com/nuxt/ui/tree/v4/src/runtime/components/PageHeader.vue",
    target: "_blank"
  }
])
</script>

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

예시 (Examples)

[!NOTE]

이 예시들은 Nuxt Content를 사용하지만, 컴포넌트는 어떤 콘텐츠 관리 시스템과도 통합할 수 있어요.

페이지 안에서 (Within a page)

페이지 안에 PageHeader 컴포넌트를 사용해 페이지 헤더를 표시해요.

<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>
  <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

/**
 * Props for the PageHeader component
 */
interface PageHeaderProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  headline?: string | undefined;
  title?: string | undefined;
  description?: string | undefined;
  /**
   * Display a list of Button next to the title.
   * `{ color: 'neutral', variant: 'outline' }`{lang="ts-type"}
   */
  links?: ButtonProps[] | undefined;
  ui?: { root?: SlotClass; container?: SlotClass; wrapper?: SlotClass; headline?: SlotClass; title?: SlotClass; description?: SlotClass; links?: SlotClass; } | undefined;
}

Slots

/**
 * Slots for the PageHeader component
 */
interface PageHeaderSlots {
  headline(): any;
  title(): any;
  description(): any;
  links(): any;
  default(): any;
}

테마 (Theme)

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'
          }
        }
      }
    }
  }
})

변경 이력 (Changelog)

컴포넌트와 테마의 커밋 기록을 확인하세요.


더 알아보기 (Learn more)