Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Guidance for building UIs with Nuxt UI, the official Tailwind-based component library for Nuxt.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/layouts/dashboard.md
1# Dashboard Layout23Build admin interfaces with resizable sidebars, multi-panel layouts, and toolbars.45## When to use67- Admin panels, back-office UIs8- Email clients, project management tools9- Any app with a persistent sidebar and content panels10- Combine with chat or editor layouts for specialized dashboards1112## Component tree1314```15UApp16└── NuxtLayout (dashboard)17└── UDashboardGroup18├── UDashboardSidebar19│ ├── #header (logo, search button)20│ ├── #default (navigation) — receives { collapsed } slot prop21│ └── #footer (user menu)22└── NuxtPage23└── UDashboardPanel24├── #header → UDashboardNavbar + UDashboardToolbar25├── #body (scrollable content)26└── #footer (optional)27```2829## Layout3031```vue [layouts/dashboard.vue]32<script setup lang="ts">33import type { NavigationMenuItem } from '@nuxt/ui'3435const items = computed<NavigationMenuItem[]>(() => [{36label: 'Home',37icon: 'i-lucide-house',38to: '/dashboard'39}, {40label: 'Inbox',41icon: 'i-lucide-inbox',42to: '/dashboard/inbox'43}, {44label: 'Users',45icon: 'i-lucide-users',46to: '/dashboard/users'47}, {48label: 'Settings',49icon: 'i-lucide-settings',50to: '/dashboard/settings'51}])52</script>5354<template>55<UDashboardGroup>56<UDashboardSidebar collapsible resizable>57<template #header="{ collapsed }">58<UDashboardSearchButton :collapsed="collapsed" />59</template>6061<template #default="{ collapsed }">62<UNavigationMenu63:collapsed="collapsed"64:items="items"65orientation="vertical"66/>67</template>6869<template #footer="{ collapsed }">70<UButton71:icon="collapsed ? 'i-lucide-log-out' : undefined"72:label="collapsed ? undefined : 'Sign out'"73color="neutral"74variant="ghost"75block76/>77</template>78</UDashboardSidebar>7980<slot />81</UDashboardGroup>82</template>83```8485## Page8687```vue [pages/dashboard/index.vue]88<script setup lang="ts">89definePageMeta({ layout: 'dashboard' })90</script>9192<template>93<UDashboardPanel>94<template #header>95<UDashboardNavbar title="Home">96<template #leading>97<UDashboardSidebarCollapse />98</template>99<template #right>100<UButton icon="i-lucide-plus" label="New" />101</template>102</UDashboardNavbar>103</template>104105<template #body>106<!-- Page content -->107</template>108</UDashboardPanel>109</template>110```111112### Common mistakes113114- Forgetting `definePageMeta({ layout: 'dashboard' })` — the page won't use the dashboard layout without it.115- Putting content directly in `UDashboardPanel` without using `#body` slot — content won't scroll properly.116- Not handling the `collapsed` slot prop — sidebar content should adapt when collapsed (hide labels, center icons).117118## Key components119120### DashboardGroup121122Root wrapper. Manages sidebar state and persistence.123124| Prop | Default | Purpose |125|---|---|---|126| `storage` | `'cookie'` | `'cookie'`, `'localStorage'`, `false` |127| `storage-key` | `'dashboard'` | Storage key name |128129### DashboardSidebar130131Resizable, collapsible sidebar. Must be inside `DashboardGroup`.132133| Prop | Default | Purpose |134|---|---|---|135| `resizable` | `false` | Drag to resize |136| `collapsible` | `false` | Collapse when dragged to edge |137| `side` | `'left'` | `'left'` or `'right'` |138| `mode` | `'slideover'` | Mobile: `'modal'`, `'slideover'`, `'drawer'` |139140All slots receive `{ collapsed, collapse }` — `collapsed` is the boolean state, `collapse(value)` toggles it programmatically. Use `v-model:collapsed` and `v-model:open` (mobile) for state control.141142### DashboardPanel143144Content panel with `#header`, `#body` (scrollable), `#footer`, and `#default` (raw, no scroll) slots.145146### DashboardNavbar / DashboardToolbar147148Navbar: `#leading`, `#left`, `#default`, `#right` slots + `title` prop. Use `UDashboardSidebarCollapse` in `#leading` to toggle sidebar on mobile.149Toolbar: same slots, sits below navbar for filters/actions.150151### UNavigationMenu in sidebar152153Always pass `:collapsed="collapsed"` to `UNavigationMenu` inside a collapsible sidebar — it auto-hides labels and centers icons. Use `NavigationMenuItem[][]` (array of arrays) for separate groups (main nav + footer links).154155## Multi-panel (list-detail)156157```vue [pages/dashboard/inbox.vue]158<script setup lang="ts">159definePageMeta({ layout: 'dashboard' })160</script>161162<template>163<UDashboardPanel id="inbox-list" resizable>164<template #header>165<UDashboardNavbar title="Inbox" />166</template>167<template #body>168<!-- Email list -->169</template>170</UDashboardPanel>171172<UDashboardPanel id="inbox-detail" class="hidden lg:flex">173<template #header>174<UDashboardNavbar title="Message" />175</template>176<template #body>177<!-- Email content -->178</template>179</UDashboardPanel>180</template>181```182183## With toolbar184185```vue186<UDashboardPanel>187<template #header>188<UDashboardNavbar title="Users" />189<UDashboardToolbar>190<template #left>191<UInput icon="i-lucide-search" placeholder="Search..." />192</template>193<template #right>194<USelect :items="['All', 'Active', 'Inactive']" />195</template>196</UDashboardToolbar>197</template>198</UDashboardPanel>199```200201## With search202203```vue [layouts/dashboard.vue]204<template>205<UDashboardGroup>206<UDashboardSidebar>207<template #header>208<UDashboardSearchButton />209</template>210</UDashboardSidebar>211212<slot />213214<UDashboardSearch :groups="searchGroups" />215</UDashboardGroup>216</template>217```218219## Right sidebar220221```vue222<UDashboardGroup>223<UDashboardSidebar collapsible resizable>224<!-- Left sidebar -->225</UDashboardSidebar>226227<slot />228229<UDashboardSidebar side="right" resizable>230<!-- Right sidebar -->231</UDashboardSidebar>232</UDashboardGroup>233```234