PageAside
A sticky aside to display your page navigation.
Usage
The PageAside component is a sticky <aside> element that is only displayed starting from the lg breakpoint.
The PageAside component uses the
--ui-header-height CSS variable to position itself correctly below the Header.Use it inside the left or right slot of the Page component:
<template>
<PPage>
<template #left>
<PPageAside />
</template>
</PPage>
</template>
Examples
While these examples use Nuxt Content, the components can be integrated with any content management system.
Within a layout
Use the PageAside component in a layout to display the navigation:
layouts/docs.vue
<script setup lang="ts">
import type { ContentNavigationItem } from '@nuxt/content';
const navigation = inject<Ref<Array<ContentNavigationItem>>>('navigation');
</script>
<template>
<PPage>
<template #left>
<PPageAside>
<PContentNavigation :navigation="navigation" />
</PPageAside>
</template>
<slot />
</PPage>
</template>
In this example, we use the
ContentNavigation component to display the navigation injected in app.vue.API
Props
| Prop | Default | Type |
|---|---|---|
as | 'aside' | anyThe element or component this component should render as. |
ui | { root?: SlotClass; container?: SlotClass; top?: SlotClass; topHeader?: SlotClass; topBody?: SlotClass; topFooter?: SlotClass; } |
Slots
| Slot | Type |
|---|---|
top | {} |
default | {} |
bottom | {} |
Theme
app.config.ts
export default defineAppConfig({
ui: {
pageAside: {
slots: {
root: 'py-8 hidden overflow-y-auto lg:pe-6.5 lg:ps-4 lg:max-h-[calc(100vh-var(--ui-header-height))] lg:block lg:top-$ui-header-height lg:sticky lg:-ms-4',
container: 'relative',
top: 'sticky -top-8 -mt-8 pointer-events-none z-1',
topHeader: 'h-8 bg-background -mx-4 px-4',
topBody: 'bg-background relative pointer-events-auto flex flex-col -mx-4 px-4',
topFooter: 'px-4 h-8 from-background bg-gradient-to-b -mx-4'
}
}
}
})vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from 'pohon-ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
pageAside: {
slots: {
root: 'py-8 hidden overflow-y-auto lg:pe-6.5 lg:ps-4 lg:max-h-[calc(100vh-var(--ui-header-height))] lg:block lg:top-$ui-header-height lg:sticky lg:-ms-4',
container: 'relative',
top: 'sticky -top-8 -mt-8 pointer-events-none z-1',
topHeader: 'h-8 bg-background -mx-4 px-4',
topBody: 'bg-background relative pointer-events-auto flex flex-col -mx-4 px-4',
topFooter: 'px-4 h-8 from-background bg-gradient-to-b -mx-4'
}
}
}
})
]
})Changelog
No recent changes