DashboardDécouvrez
Utilisation
Le composant DashboardNavbar est une barre de navigation réactive qui s'intègre au composant DashboardSidebar. Il comprend un bouton de bascule mobile pour activer la navigation réactive dans les mises en page de tableau de bord.
Utilisez-le à l'intérieur de l'emplacement header du composant DashboardPanel:
<script setup lang="ts">
definePageMeta({
layout: 'dashboard'
})
</script>
<template>
<UDashboardPanel>
<template #header>
<UDashboardNavbar />
</template>
</UDashboardPanel>
</template>
Utilisez les slots left, default et right pour personnaliser la barre de navigation.
Inbox
4<script setup lang="ts">
import type { TabsItem } from '@nuxt/ui'
const items: TabsItem[] = [
{
label: 'All',
value: 'all'
},
{
label: 'Unread',
value: 'unread'
}
]
</script>
<template>
<UDashboardNavbar title="Inbox">
<template #leading>
<UDashboardSidebarCollapse />
</template>
<template #trailing>
<UBadge label="4" variant="subtle" />
</template>
<template #right>
<UTabs :items="items" default-value="all" size="sm" class="w-40" :content="false" />
</template>
</UDashboardNavbar>
</template>Titre
Utilisez le prop title pour définir le titre de la barre de navigation.
Dashboard
<template>
<UDashboardNavbar title="Dashboard" />
</template>icône
Utilisez le prop icon pour définir l'icône de la barre de navigation.
Dashboard
<template>
<UDashboardNavbar title="Dashboard" icon="i-lucide-house" />
</template>Télécharger
Use the toggle prop to customize the toggle button displayed on mobile that opens the DashboardSidebar component.
Vous pouvez passer n'importe quelle propriété du composant Button pour le personnaliser.
<template>
<UDashboardNavbar
title="Dashboard"
:toggle="{
color: 'primary',
variant: 'subtle',
class: 'rounded-full'
}"
/>
</template>
Toggle Côté
Utilisez la prop toggle-side pour changer le côté du bouton bascule. Par défaut, right.
<template>
<UDashboardNavbar
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; } |
thème
export default defineAppConfig({
ui: {
dashboardNavbar: {
slots: {
root: 'h-(--ui-header-height) shrink-0 flex items-center justify-between border-b border-default px-4 sm:px-6 gap-1.5',
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-semibold 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 '@nuxt/ui/vite'
export default defineConfig({
plugins: [
vue(),
ui({
ui: {
dashboardNavbar: {
slots: {
root: 'h-(--ui-header-height) shrink-0 flex items-center justify-between border-b border-default px-4 sm:px-6 gap-1.5',
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-semibold text-highlighted truncate',
center: 'hidden lg:flex',
right: 'flex items-center shrink-0 gap-1.5',
toggle: ''
},
variants: {
toggleSide: {
left: {
toggle: ''
},
right: {
toggle: ''
}
}
}
}
}
})
]
})