DXDashboardSidebar
A collapsible sidebar navigation component for Laravel dashboards with support for navigation groups, icons, badges, and active state highlighting.
Live Examples
Props
| Name Click to sort ascending | Type | Required Click to sort ascending | Default | Description |
|---|---|---|---|---|
navigation | Navigation | Yes | - | Navigation structure with groups and items. See Navigation type definition below |
currentUrl | string | Yes | - | Current URL for determining active navigation items |
collapsed | boolean | No | false | Whether the sidebar rail is collapsed to icons only |
title | string | No | Dashboard | Sidebar title shown in the header |
collapsibleGroups | boolean | No | false | Turn group headers into accordion toggles that collapse/expand their items |
autoCollapseInactiveGroups | boolean | No | true | When collapsibleGroups is on: true opens only the active-route group and closes others when one opens (single-open accordion); false opens all groups and toggles them independently |
variant | 'light' | 'dark' | No | 'light' | Colour scheme. light: white pane, tinted group-header pills, grey links, green active item, Poppins. dark: the navy rail. Colours come from the --dx-sidebar-* custom properties (see the theming guide) |
phoneMenu | boolean | No | false | Below 576px (the theme's sm), show the open sidebar as a full-screen menu with a close button, hidden until opened. The owner must close it on close, navigate and Escape: DXDashboard sets it and does. Without it the sidebar keeps its rail on phones and has no close button |
Events
| Name Click to sort ascending | Parameters | Description |
|---|---|---|
toggle | none | Emitted when the sidebar should toggle between collapsed and expanded states |
close | none | Emitted by the close button in the header, rendered only with phoneMenu and shown only below 576px, where the open sidebar covers the screen |
navigate | none | Emitted when a link anywhere in the sidebar is followed (a plain click; new-tab clicks are ignored): the navigation, the link slot, and the brand and footer slots. DXDashboard closes its phone menu on it |
Slots
| Name Click to sort ascending | Description | Scoped Props |
|---|---|---|
brand | Custom brand/logo content in the sidebar header. Receives collapsed (boolean) and title (string) as slot props | - |
link | Custom navigation link rendering. Receives item (your navigation item type, NavigationItem by default; see Your own item type below), isActive (boolean), collapsed (boolean), and isExpanded (boolean — whether the containing group is open) as slot props | - |
footer | Utility/secondary links pinned to the bottom of the sidebar, below the nav groups. Receives collapsed (boolean) as a slot prop | - |
Extended Component
This is a custom component that extends beyond simple Bootstrap Vue Next wrappers, providing additional functionality specific to Laravel dashboards.
Navigation Type
The Navigation type is an array of NavigationGroup objects:
interface NavigationItem {
label: string;
url: string;
icon?: string; // Icon component or emoji
badge?: string | number; // Badge content
badgeColor?: string; // Bootstrap colour variant
active?: boolean;
visible?: boolean;
}
interface NavigationGroup {
label?: string; // Group label (optional)
items: NavigationItem[];
collapsible?: boolean; // Set false to keep this group always expanded when collapsibleGroups is on
collapsed?: boolean; // Reserved for a future explicit initial-open hint
visible?: boolean;
}
type Navigation = NavigationGroup[];
Your own item type
NavigationGroup and Navigation take the item type as a parameter
(Navigation<YourItem>, defaulting to NavigationItem), and the sidebar infers
it from the navigation prop, so the link slot’s item has the keys your
items carry:
<script setup lang="ts">
import { DXDashboardSidebar } from '@omnitend/dashboard-for-laravel';
import type { Navigation, NavigationItem } from '@omnitend/dashboard-for-laravel';
interface AppNavigationItem extends NavigationItem {
routeName: string;
}
const navigation: Navigation<AppNavigationItem> = [
{ items: [{ label: 'Orders', url: '/orders', routeName: 'orders.index' }] },
];
</script>
<template>
<DXDashboardSidebar :navigation="navigation" current-url="/orders">
<template #link="{ item, isActive }">
<!-- item.routeName is a string; a misspelt key is an error -->
<a :href="item.url" :data-route="item.routeName" :class="{ active: isActive }">
{{ item.label }}
</a>
</template>
</DXDashboardSidebar>
</template>
A plain Navigation gives a NavigationItem; navigation typed any gives an
any item. DXDashboard’s sidebar-link slot is typed the same way.
Template refs
Type a template ref with useTemplateRef('name'), which needs nothing extra.
Because the sidebar is generic (over its navigation type), the ref carries
only what the sidebar exposes: el, its root <aside> element (null before
mount). There is no $el or $props, and InstanceType<typeof DXDashboardSidebar> does not compile.
<script setup lang="ts">
import { useTemplateRef } from 'vue';
import { DXDashboardSidebar } from '@omnitend/dashboard-for-laravel';
import type { Navigation } from '@omnitend/dashboard-for-laravel';
const navigation: Navigation = [
{ items: [{ label: 'Orders', url: '/orders' }] },
];
const sidebar = useTemplateRef('sidebarRef');
// HTMLElement | null (undefined while the ref is unset).
const sidebarWidth = () => sidebar.value?.el?.getBoundingClientRect().width ?? 0;
</script>
<template>
<DXDashboardSidebar ref="sidebarRef" :navigation="navigation" current-url="/orders" />
</template>
If you need the ref’s type by name, the optional alternative is
ComponentExposed<typeof DXDashboardSidebar> from the
vue-component-type-helpers package, which you have to install yourself.
Features
- Collapsible Design: Toggle between expanded and collapsed (icon-only) rail states
- Collapsible Groups: Optional accordion menu groups (
collapsibleGroups) — ideal for large menus. WithautoCollapseInactiveGroups(default), only the active-route group opens on load and opening one closes the others. Uses a CSS grid height transition (no layout flicker on load) - Navigation Groups: Organise navigation items into logical groups with labels
- Active State: Automatically highlights active navigation items based on current URL
- Icon Support: Display icons next to navigation items (works with component icons or emojis)
- Badges: Show notification badges on navigation items
- Sticky Positioning: Sidebar stays in view when scrolling
- Custom Scrollbar: Styled scrollbar for better aesthetics
- Flexible Rendering: Use slots to completely customise brand and link rendering