DashboardNavbar
Usage
The DashboardNavbar component is a responsive navigation bar that integrates with the DashboardSidebar component. It includes a mobile toggle button to enable responsive navigation in dashboard layouts.
Use it inside the header slot of the DashboardPanel component:
<script setup lang="ts">
definePageMeta({
layout: 'dashboard'
});
</script>
<template>
<PDashboardPanel>
<template #header>
<PDashboardNavbar />
</template>
</PDashboardPanel>
</template>
Use the left, default and right slots to customize the navbar.
Inbox
4<script setup lang="ts">
import type { TabsItem } from 'pohon-ui'
const items: Array<TabsItem> = [
{
label: 'All',
value: 'all'
},
{
label: 'Unread',
value: 'unread'
}
]
</script>
<template>
<PDashboardNavbar title="Inbox">
<template #leading>
<PDashboardSidebarCollapse />
</template>
<template #trailing>
<PBadge label="4" variant="subtle" />
</template>
<template #right>
<PTabs :items="items" default-value="all" size="sm" class="w-40" :content="false" />
</template>
</PDashboardNavbar>
</template>Title Soon
Use the title prop to set the title of the navbar.
Dashboard
<template>
<PDashboardNavbar title="Dashboard" />
</template>h1 by default. Use the as prop with an object to change it, for example :as="{ title: 'h2' }". You can also set the root element this way: :as="{ root: 'section', title: 'h2' }".Icon
Use the icon prop to set the icon of the navbar.
Dashboard
<template>
<PDashboardNavbar title="Dashboard" icon="i-lucide-house" />
</template>Toggle
Use the toggle prop to customize the toggle button displayed on mobile that opens the DashboardSidebar component.
You can pass any property from the Button component to customize it.
<template>
<PDashboardNavbar
title="Dashboard"
:toggle="{
color: 'primary',
variant: 'subtle',
class: 'rounded-full',
}"
/>
</template>
Toggle Side
Use the toggle-side prop to change the side of the toggle button. Defaults to right.
<template>
<PDashboardNavbar
title="Dashboard"
toggle-side="right"
/>
</template>
API
Props
| Prop | Default | Type |
|---|---|---|
as | 'div' | anyThe element or component this component should render as. |
icon | anyThe icon displayed next to the title. | |
title | string | |
toggle | true | boolean | Omit<ButtonProps, LinkPropsKeys> Customize the toggle button to open the sidebar.
|
toggleSide | 'left' | "left" | "right"The side to render the toggle button on. |
ui | { root?: SlotClass; left?: SlotClass; icon?: SlotClass; title?: SlotClass; center?: SlotClass; right?: SlotClass; toggle?: SlotClass; } |
Slots
| Slot | Type |
|---|---|
title | {} |
leading | DashboardNavbarSlotsProps & { ui: object; } |
trailing | DashboardNavbarSlotsProps & { ui: object; } |
left | DashboardNavbarSlotsProps |
default | DashboardNavbarSlotsProps |
right | DashboardNavbarSlotsProps |
toggle | DashboardNavbarSlotsProps & { ui: object; } |
Theme
export default defineAppConfig({
ui: {
dashboardNavbar: {
slots: {
root: 'border-border px-4 border-b flex shrink-0 gap-1.5 h-$ui-header-height items-center justify-between sm:px-6',
left: 'flex items-center gap-1.5 min-w-0',
icon: 'shrink-0 size-5 self-center me-1.5',
title: 'flex items-center gap-1.5 font-600 color-text-highlighted truncate',
center: 'hidden lg:flex',
right: 'flex items-center shrink-0 gap-1.5',
toggle: ''
},
variants: {
toggleSide: {
left: {
toggle: ''
},
right: {
toggle: ''
}
}
}
}
}
})import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import ui from 'pohon-ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
dashboardNavbar: {
slots: {
root: 'border-border px-4 border-b flex shrink-0 gap-1.5 h-$ui-header-height items-center justify-between sm:px-6',
left: 'flex items-center gap-1.5 min-w-0',
icon: 'shrink-0 size-5 self-center me-1.5',
title: 'flex items-center gap-1.5 font-600 color-text-highlighted truncate',
center: 'hidden lg:flex',
right: 'flex items-center shrink-0 gap-1.5',
toggle: ''
},
variants: {
toggleSide: {
left: {
toggle: ''
},
right: {
toggle: ''
}
}
}
}
}
})
]
})