DDBS UI
navigation

App Sidebar

An application sidebar with grouped navigation, expandable children, count badges, search with a results listbox, a promo slot and a pinned footer. Collapses to an icon rail and becomes a drawer on mobile.

npx shadcn@latest add https://ui.develop-better-solutions.com/r/app-sidebar.json
Dependencies:lucide-react
Fullscreen
Active: warehouse

Usage

app-sidebar-example.tsx
"use client";

import { useState } from "react";
import { BarChart3, Home, LifeBuoy, Settings, Truck, Users } from "lucide-react";
import { AppSidebar } from "@dbs/ui";

export default function AppSidebarExample() {
  const [active, setActive] = useState("warehouse");
  const [mobile, setMobile] = useState(false);
  const icon = "h-[18px] w-[18px]";
  const link = (id: string) => ({ onClick: () => setActive(id) });
  return (
    <div className="flex h-[560px] w-full overflow-hidden rounded-2xl border border-line [transform:translateZ(0)]">
      <AppSidebar
        brand={<span className="text-lg font-semibold">Fleetwise</span>}
        activeId={active}
        mobileOpen={mobile}
        onMobileClose={() => setMobile(false)}
        onSearch={(q) =>
          ["Dashboard", "Warehouse", "Drivers", "Reports"]
            .filter((l) => l.toLowerCase().includes(q.toLowerCase()))
            .map((l) => ({ id: l, label: l, hint: "Page", onSelect: () => setActive(l.toLowerCase()) }))
        }
        sections={[
          {
            id: "main",
            title: "Main menu",
            items: [
              { id: "dashboard", label: "Dashboard", icon: <Home className={icon} />, ...link("dashboard") },
              {
                id: "fleet",
                label: "Fleet management",
                icon: <Truck className={icon} />,
                children: [
                  { id: "vehicles", label: "All vehicles", href: "#" },
                  { id: "repairs", label: "Maintenance", href: "#", badge: 2 },
                ],
              },
              { id: "warehouse", label: "Warehouse", icon: <BarChart3 className={icon} />, ...link("warehouse") },
            ],
          },
          {
            id: "support",
            title: "Support",
            items: [
              { id: "team", label: "Team and roles", icon: <Users className={icon} />, ...link("team") },
              { id: "help", label: "Help", icon: <LifeBuoy className={icon} />, ...link("help") },
            ],
          },
        ]}
        promo={
          <div className="rounded-xl border border-line bg-canvas p-3">
            <p className="text-[13px] font-medium">Premium plan</p>
            <p className="mt-0.5 text-[11px] text-ink-subtle">Sending more now is not a concern</p>
          </div>
        }
        footer={<p className="flex items-center gap-2 text-[13px] text-ink-muted"><Settings className="h-4 w-4" /> Settings</p>}
      />
      <div className="flex-1 p-6 text-sm text-ink-subtle">
        Active: {active}
        <button type="button" onClick={() => setMobile(true)} className="ml-4 rounded-full border border-line px-3 py-1 text-xs lg:hidden">
          Open drawer
        </button>
      </div>
    </div>
  );
}