pageheader
Un header responsive pour vos pages.
Utilisation
Le composant PageHeader affiche un header pour votre page.
Utilisez-le dans l'emplacement par défaut du composant Page, avant le composant PageBody:
<template>
<UPage>
<UPageHeader />
<UPageBody />
</UPage>
</template>
Titre
Use the title prop to display a title in the header.
PageHeader
<template>
<UPageHeader title="PageHeader" />
</template>Description
Utilisez la prop description pour afficher une description dans l'en-tête.
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>Référencement
Utilisez le prop headline pour afficher un titre dans l'en-tête.
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>Liens
Utilisez la prop links pour afficher une liste de Button dans l'en-tête.
Components
PageHeader
A responsive page header with title, description and actions.
<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><script setup lang="ts">
import { ref } from 'vue'
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>Exemples
Bien que ces exemples utilisent Nuxt Content, les composants peuvent être intégrés à n'importe quel système de gestion de contenu.
Au sein d'une page
Utilisez le composant PageHeader dans une page pour afficher l'en-tête de la page:
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>
<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 équipements
| Prop | Default | Type |
|---|---|---|
as | 'div' | anyThe 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.
| |
ui | { root?: SlotClass; container?: SlotClass; wrapper?: SlotClass; headline?: SlotClass; title?: SlotClass; description?: SlotClass; links?: SlotClass; } |
Slots
| Slot | Type |
|---|---|
headline | {} |
title | {} |
description | {} |
links | {} |
default | {} |
Thème
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 '@nuxt/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 écrit
No recent changes