PageLinks
Usage
Links
Use the links
prop as an array of objects with the following properties:
label: string
icon?: string
You can pass any property from the Link component such as to
, target
, etc.
<script setup lang="ts">
const links = ref([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui-pro/tree/v3/docs/content/3.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Roadmap',
icon: 'i-lucide-map',
to: '/roadmap'
}
])
</script>
<template>
<UPageLinks :links="links" />
</template>
Title
Use the title
prop to display a title above the links.
<script setup lang="ts">
const links = ref([
{
label: 'Edit this page',
icon: 'i-lucide-file-pen',
to: 'https://github.com/nuxt/ui-pro/tree/v3/docs/content/3.components/page-links.md'
},
{
label: 'Star on GitHub',
icon: 'i-lucide-star',
to: 'https://github.com/nuxt/ui'
},
{
label: 'Roadmap',
icon: 'i-lucide-map',
to: '/roadmap'
}
])
</script>
<template>
<UPageLinks title="Community" :links="links" />
</template>
Examples
Within a page
Use the PageLinks component in the bottom
slot of the ContentToc component to display a list of links below the table of contents.
<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)
})
const links = computed(() => [{
icon: 'i-lucide-file-pen',
label: 'Edit this page',
to: `https://github.com/nuxt/ui/edit/v3/docs/content/${page?.value?.stem}.md`,
target: '_blank'
}, {
icon: 'i-lucide-star',
label: 'Star on GitHub',
to: 'https://github.com/nuxt/ui',
target: '_blank'
}, {
label: 'Roadmap',
icon: 'i-lucide-map',
to: '/roadmap'
}])
</script>
<template>
<UPage>
<UPageHeader :title="page.title" :description="page.description" />
<UPageBody>
<ContentRenderer :value="page" />
<USeparator />
<UContentSurround :surround="surround" />
</UPageBody>
<template #right>
<UContentToc :links="page.body.toc.links">
<template #bottom>
<USeparator type="dashed" />
<UPageLinks title="Community" :links="links" />
</template>
</UContentToc>
</template>
</UPage>
</template>
API
Props
Prop | Default | Type |
---|---|---|
as |
|
The element or component this component should render as. |
title |
| |
links |
| |
ui |
|
Slots
Slot | Type |
---|---|
title |
|
link |
|
link-leading |
|
link-label |
|
link-trailing |
|
Theme
export default defineAppConfig({
uiPro: {
pageLinks: {
slots: {
root: 'flex flex-col gap-3',
title: 'text-sm font-semibold flex items-center gap-1.5',
list: 'flex flex-col gap-2',
item: 'relative',
link: 'group text-sm flex items-center gap-1.5 focus-visible:outline-[var(--ui-primary)]',
linkLeadingIcon: 'size-5 shrink-0',
linkLabel: 'truncate',
linkLabelExternalIcon: 'size-3 absolute top-0 text-[var(--ui-text-dimmed)]'
},
variants: {
active: {
true: {
link: 'text-[var(--ui-primary)] font-medium'
},
false: {
link: [
'text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]',
'transition-colors'
]
}
}
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
uiPro: {
pageLinks: {
slots: {
root: 'flex flex-col gap-3',
title: 'text-sm font-semibold flex items-center gap-1.5',
list: 'flex flex-col gap-2',
item: 'relative',
link: 'group text-sm flex items-center gap-1.5 focus-visible:outline-[var(--ui-primary)]',
linkLeadingIcon: 'size-5 shrink-0',
linkLabel: 'truncate',
linkLabelExternalIcon: 'size-3 absolute top-0 text-[var(--ui-text-dimmed)]'
},
variants: {
active: {
true: {
link: 'text-[var(--ui-primary)] font-medium'
},
false: {
link: [
'text-[var(--ui-text-muted)] hover:text-[var(--ui-text)]',
'transition-colors'
]
}
}
}
}
}
})
]
})