대시보드 내비게이션 바
대시보드 내비게이션 바 (DashboardNavbar)
대시보드에 표시하는 반응형 내비게이션 바 컴포넌트예요. 사이드바와 연동되며 모바일에서는 토글 버튼으로 내비게이션을 여닫을 수 있어요.
출처: Nuxt UI
본문
대시보드에 표시하는 반응형 내비게이션 바예요.
사용 방법 (Usage)
DashboardNavbar 컴포넌트는 DashboardSidebar 컴포넌트와 연동되는 반응형 내비게이션 바예요. 대시보드 레이아웃에서 반응형 내비게이션을 사용할 수 있도록 모바일용 토글 버튼을 제공합니다.
DashboardPanel 컴포넌트의 header 슬롯 안에 사용하세요:
<script setup lang="ts">
definePageMeta({
layout: 'dashboard'
})
</script>
<template>
<UDashboardPanel>
<template #header>
<UDashboardNavbar />
</template>
</UDashboardPanel>
</template>
left, default, right 슬롯을 사용하면 내비게이션 바를 자유롭게 꾸밀 수 있어요.
<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>
[!NOTE]
이 예시에서는 right 슬롯에 Tabs 컴포넌트를 사용해 탭 몇 개를 표시했어요.
제목 (Title)
title prop을 사용하면 내비게이션 바의 제목을 설정할 수 있어요.
<template>
<UDashboardNavbar title="Dashboard" />
</template>
아이콘 (Icon)
icon prop을 사용하면 내비게이션 바의 아이콘을 설정할 수 있어요.
<template>
<UDashboardNavbar title="Dashboard" icon="i-lucide-house" />
</template>
토글 (Toggle)
toggle prop을 사용하면 모바일에서 DashboardSidebar 컴포넌트를 여는 토글 버튼을 꾸밀 수 있어요.
Button 컴포넌트의 어떤 속성이든 넘겨서 토글 버튼을 커스터마이즈할 수 있습니다.
<template>
<UDashboardNavbar
title="Dashboard"
:toggle="{
color: 'primary',
variant: 'subtle',
class: 'rounded-full'
}"
/>
</template>
토글 위치 (Toggle Side)
toggle-side prop을 사용하면 토글 버튼의 위치를 바꿀 수 있어요. 기본값은 right예요.
<template>
<UDashboardNavbar
title="Dashboard"
toggle-side="right"
/>
</template>
API
Props
/**
* Props for the DashboardNavbar component
*/
interface DashboardNavbarProps {
/**
* The element or component this component should render as.
* @default 'div'
*/
as?: any;
/**
* The icon displayed next to the title.
*/
icon?: any;
title?: string | undefined;
/**
* Customize the toggle button to open the sidebar.
* `{ color: 'neutral', variant: 'ghost' }`{lang="ts-type"}
* @default true
*/
toggle?: boolean | Omit<ButtonProps, LinkPropsKeys> | undefined;
/**
* The side to render the toggle button on.
* @default 'left'
*/
toggleSide?: "left" | "right" | undefined;
ui?: { root?: SlotClass; left?: SlotClass; icon?: SlotClass; title?: SlotClass; center?: SlotClass; right?: SlotClass; toggle?: SlotClass; } | undefined;
}
Slots
/**
* Slots for the DashboardNavbar component
*/
interface DashboardNavbarSlots {
title(): any;
leading(): any;
trailing(): any;
left(): any;
default(): any;
right(): any;
toggle(): any;
}
테마 (Theme)
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: ''
}
}
}
}
}
})