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