ダッシュボードNavbar

ダッシュボードに表示するレスポンシブなナビバー。

使用法

DashboardNavbarコンポーネントは、DashboardSidebarコンポーネントと統合されたレスポンシブナビゲーションバーです。ダッシュボードレイアウトでレスポンシブナビゲーションを有効にするモバイルトグルボタンが含まれています。

DashboardPanelコンポーネントのheaderスロット内で使用します。

pages/index.vue
<script setup lang="ts">
definePageMeta({
  layout: 'dashboard'
})
</script>

<template>
  <UDashboardPanel>
    <template #header>
      <UDashboardNavbar />
    </template>
  </UDashboardPanel>
</template>

navbarをカスタマイズするには、left、default、rightスロットを使用します。

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>
この例では、右スロットのTabsコンポーネントを使用してタブを表示します。

Title

titleプロパティを使用して、ナビバーのタイトルを設定します。

Dashboard

<template>
  <UDashboardNavbar title="Dashboard" />
</template>

Icon

iconプロパティを使用して、ナビバーのアイコンを設定します。

Dashboard

<template>
  <UDashboardNavbar title="Dashboard" icon="i-lucide-house" />
</template>

Toggle

toggleプロパティを使用して、DashboardSidebarコンポーネントを開くモバイルに表示されるトグルボタンをカスタマイズします。

Buttonコンポーネントの任意のプロパティを渡してカスタマイズできます。

<template>
  <UDashboardNavbar
    title="Dashboard"
    :toggle="{
      color: 'primary',
      variant: 'subtle',
      class: 'rounded-full'
    }"
  />
</template>

Toggle側

トグルボタンの側面を変更するには、toggle-sideプロパティを使用します。デフォルトはrightです。

<template>
  <UDashboardNavbar
    title="Dashboard"
    toggle-side="right"
  />
</template>

API

Props

Prop Default Type
as
'div'
any

The element or component this component should render as.

icon
any

The icon displayed next to the title.

title
string
toggle
true
boolean | Omit<ButtonProps, LinkPropsKeys>

Customize the toggle button to open the sidebar. { color: 'neutral', variant: 'ghost' }

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; }

スロット

Slot Type
title
{}
leading
DashboardNavbarSlotsProps & { ui: object; }
trailing
DashboardNavbarSlotsProps & { ui: object; }
left
DashboardNavbarSlotsProps
default
DashboardNavbarSlotsProps
right
DashboardNavbarSlotsProps
toggle
DashboardNavbarSlotsProps & { ui: object; }

Theme

app.config.ts
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: ''
          }
        }
      }
    }
  }
})
vite.config.ts
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: ''
              }
            }
          }
        }
      }
    })
  ]
})

Changelog

No recent changes