Skip to content
Product block

Sidebar Dashboard Shell

Sidebar, top bar and scrollable content slot, with a mobile drawer that closes on Escape and marks the active route.

218 lineslucide-reactAdded 8 Aug 2026Updated 11 Sept 2026
  • dashboard
  • sidebar
  • layout
  • shell
  • admin

What's included

  • components/dashboard-shell.tsx
  • Needs lucide-react

Works with

  • React
  • Next.js
  • Tailwind CSS
  • TypeScript

npx hoverlab add dashboard-shell

Or over MCP, from your editor's agent — no account needed.

License

Free to read, copy and install, for personal and non-commercial projects. Shipping it in client work or a paid product needs Pro ($79 once). The source lands in your repo and stops being ours — no attribution, nothing to upgrade.

Was this useful?

Start a page with this section — add more, order them, and leave with the page source.

Preview

Your page content goes here

Rendered live in your current theme — this is the same component whose source is below, not a screenshot of it.

Source

components/dashboard-shell.tsx
'use client'

/**
 * <DashboardShell> — sidebar, top bar and a content slot.
 *
 * The layout every internal tool needs and nobody enjoys rebuilding.
 *
 *  - The sidebar is a real <nav> with `aria-current="page"` on the active
 *    item, which is what a screen reader uses to answer "where am I".
 *  - Below `lg` it becomes a drawer over a backdrop, with `aria-expanded`
 *    on the trigger. Escape closes it — a drawer you can only dismiss by
 *    finding the exact backdrop pixel is a trap on a phone.
 *  - The main region scrolls independently of the sidebar, so a long table
 *    never carries the navigation off the top of the screen.
 */

import * as React from 'react'
import {
  LayoutDashboard,
  Users,
  BarChart3,
  Settings,
  Menu,
  X,
  Search,
  Bell,
} from 'lucide-react'

export interface NavItem {
  label: string
  icon: React.ReactNode
  href?: string
  badge?: string
}

export interface DashboardShellProps {
  brand?: string
  nav?: NavItem[]
  activeLabel?: string
  user?: { name: string; email: string }
  children?: React.ReactNode
  className?: string
}

const DEFAULT_NAV: NavItem[] = [
  { label: 'Overview', icon: <LayoutDashboard className="h-4 w-4" /> },
  { label: 'Customers', icon: <Users className="h-4 w-4" />, badge: '12' },
  { label: 'Analytics', icon: <BarChart3 className="h-4 w-4" /> },
  { label: 'Settings', icon: <Settings className="h-4 w-4" /> },
]

export function DashboardShell({
  brand = 'Acme Inc',
  nav = DEFAULT_NAV,
  activeLabel = 'Overview',
  user = { name: 'Ada Lovelace', email: 'ada@acme.com' },
  children,
  className = '',
}: DashboardShellProps) {
  const [open, setOpen] = React.useState(false)
  const uid = React.useId()

  // Escape closes the mobile drawer. Bound on the document rather than the
  // panel so it works regardless of where focus currently sits.
  React.useEffect(() => {
    if (!open) return
    const onKey = (e: KeyboardEvent) => {
      if (e.key === 'Escape') setOpen(false)
    }
    document.addEventListener('keydown', onKey)
    return () => document.removeEventListener('keydown', onKey)
  }, [open])

  const sidebar = (
    <div className="flex h-full flex-col">
      <div className="flex h-14 items-center gap-2 border-b border-border/60 px-5">
        <span className="flex h-7 w-7 items-center justify-center rounded-lg bg-primary text-xs font-bold text-primary-foreground">
          {brand.slice(0, 1)}
        </span>
        <span className="truncate font-semibold tracking-tight">{brand}</span>
      </div>

      <nav aria-label="Main" className="flex-1 space-y-1 p-3">
        {nav.map((item) => {
          const active = item.label === activeLabel
          return (
            <a
              key={item.label}
              href={item.href ?? '#'}
              aria-current={active ? 'page' : undefined}
              className={`flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors ${
                active
                  ? 'bg-primary/10 text-primary'
                  : 'text-muted-foreground hover:bg-muted hover:text-foreground'
              }`}
            >
              {item.icon}
              <span className="min-w-0 flex-1 truncate">{item.label}</span>
              {item.badge ? (
                <span className="rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground">
                  {item.badge}
                </span>
              ) : null}
            </a>
          )
        })}
      </nav>

      <div className="border-t border-border/60 p-3">
        <div className="flex items-center gap-3 rounded-xl px-2 py-2">
          <span className="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-bold">
            {user.name.split(' ').map((w) => w[0]).slice(0, 2).join('')}
          </span>
          <span className="min-w-0">
            <span className="block truncate text-sm font-medium">{user.name}</span>
            <span className="block truncate text-xs text-muted-foreground">{user.email}</span>
          </span>
        </div>
      </div>
    </div>
  )

  return (
    <div className={`flex h-[32rem] overflow-hidden rounded-2xl border border-border/60 bg-background ${className}`}>
      {/* Static sidebar from lg up */}
      <aside className="hidden w-60 shrink-0 border-e border-border/60 bg-card/40 lg:block">
        {sidebar}
      </aside>

      {/* Drawer below lg */}
      {open ? (
        <>
          <div
            aria-hidden
            onClick={() => setOpen(false)}
            className="absolute inset-0 z-30 bg-black/40 backdrop-blur-sm lg:hidden border border-transparent"
          />
          <aside
            id={`${uid}-nav-drawer`}
            role="dialog"
            aria-modal="true"
            aria-label="Navigation"
            className="absolute inset-y-0 start-0 z-40 w-60 border-e border-border/60 bg-card shadow-xl lg:hidden"
          >
            <button
              type="button"
              onClick={() => setOpen(false)}
              aria-label="Close navigation"
              className="absolute end-2 top-3 rounded-lg p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
            >
              <X aria-hidden className="h-4 w-4" />
            </button>
            {sidebar}
          </aside>
        </>
      ) : null}

      {/* Main column */}
      <div className="flex min-w-0 flex-1 flex-col">
        <header className="flex h-14 shrink-0 items-center gap-3 border-b border-border/60 px-4">
          <button
            type="button"
            onClick={() => setOpen(true)}
            aria-label="Open navigation"
            aria-expanded={open}
            /*
              Only while the drawer exists.

              Unlike the drawer in `nav-mobile-drawer`, this one is
              unmounted when closed — so a permanent `aria-controls` would
              be an IDREF pointing at nothing, which is worse than none at
              all: it tells assistive tech to go somewhere and then does
              not arrive.
            */
            aria-controls={open ? `${uid}-nav-drawer` : undefined}
            className="rounded-lg p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground lg:hidden"
          >
            <Menu aria-hidden className="h-4 w-4" />
          </button>

          <div className="relative max-w-xs flex-1">
            <Search
              aria-hidden
              className="pointer-events-none absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
            />
            <input
              type="search"
              placeholder="Search"
              aria-label="Search"
              className="w-full rounded-xl border border-border/60 bg-background py-1.5 ps-9 pe-3 text-sm outline-none transition-shadow placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-primary"
            />
          </div>

          <button
            type="button"
            aria-label="Notifications, 3 unread"
            className="relative ms-auto rounded-lg p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
          >
            <Bell aria-hidden className="h-4 w-4" />
            <span
              aria-hidden
              className="absolute end-1.5 top-1.5 h-2 w-2 rounded-full bg-primary ring-2 ring-background border border-transparent"
            />
          </button>
        </header>

        <main className="flex-1 overflow-y-auto p-6">
          {children ?? (
            <div className="flex h-full items-center justify-center rounded-xl border border-dashed border-border/60 text-sm text-muted-foreground">
              Your page content goes here
            </div>
          )}
        </main>
      </div>
    </div>
  )
}

Before you paste

  • Styling is Tailwind utility classes on semantic tokens (bg-card, text-muted-foreground) — it inherits your theme instead of overriding it.
  • Install: npm i lucide-react
  • Every prop has a default, so it renders standalone before you wire it up.

Where it goes

Drop it at components/dashboard-shell.tsx and import it where you need the section:

import { DashboardShell } from '@/components/dashboard-shell'

Customize

2 of this block’s props are simple enough to drive from here. Change them and the block below re-renders — it is the same component whose source is above, not a mock of it. Everything else it accepts is in the table underneath.

Props

Read out of the component’s own type and signature, so this cannot drift from the source below. Every prop has a default — the component renders standalone before you pass it anything.

PropTypeDefault
brandstring'Acme Inc'
navNavItem[]DEFAULT_NAV
activeLabelstring'Overview'
user{ name: string; email: string }{ name: 'Ada Lovelace', email: 'ada@acme.com' }
childrenReact.ReactNode—
classNamestring''

Not using React?

The same block rendered once to markup, wrapped as a file your framework compiles. Tailwind classes are framework-agnostic, so the design transfers intact — the behaviour does not.

This block is interactive. The markup below is its initial state with the event handlers stripped — you will need to re-wire the behaviour in your framework.

dashboard-shell.html
<!--
  Sidebar Dashboard Shell — markup from the Hoverlab catalog.

  This is the block rendered once to HTML and wrapped as a component
  file. It is not a port of the React source: the Tailwind classes carry
  the design, which is the part that took the work, and they are the same
  in every framework.

  This block is interactive in React and the handlers are NOT here.
  Buttons, toggles and menus render in their initial state and do
  nothing until you wire them up.
-->
<div class="flex h-[32rem] overflow-hidden rounded-2xl border border-border/60 bg-background ">
  <aside class="hidden w-60 shrink-0 border-e border-border/60 bg-card/40 lg:block">
    <div class="flex h-full flex-col">
      <div class="flex h-14 items-center gap-2 border-b border-border/60 px-5">
        <span class="flex h-7 w-7 items-center justify-center rounded-lg bg-primary text-xs font-bold text-primary-foreground">A</span>
        <span class="truncate font-semibold tracking-tight">Acme Inc</span>
      </div>
      <nav aria-label="Main" class="flex-1 space-y-1 p-3">
        <a href="#" aria-current="page" class="flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors bg-primary/10 text-primary">
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-layout-dashboard h-4 w-4" aria-hidden="true">
            <rect width="7" height="9" x="3" y="3" rx="1"></rect>
            <rect width="7" height="5" x="14" y="3" rx="1"></rect>
            <rect width="7" height="9" x="14" y="12" rx="1"></rect>
            <rect width="7" height="5" x="3" y="16" rx="1"></rect>
          </svg>
          <span class="min-w-0 flex-1 truncate">Overview</span>
        </a>
        <a href="#" class="flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors text-muted-foreground hover:bg-muted hover:text-foreground">
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-users h-4 w-4" aria-hidden="true">
            <path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"></path>
            <path d="M16 3.128a4 4 0 0 1 0 7.744"></path>
            <path d="M22 21v-2a4 4 0 0 0-3-3.87"></path>
            <circle cx="9" cy="7" r="4"></circle>
          </svg>
          <span class="min-w-0 flex-1 truncate">Customers</span>
          <span class="rounded-full bg-muted px-1.5 py-0.5 text-xs text-muted-foreground">12</span>
        </a>
        <a href="#" class="flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors text-muted-foreground hover:bg-muted hover:text-foreground">
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chart-column h-4 w-4" aria-hidden="true">
            <path d="M3 3v16a2 2 0 0 0 2 2h16"></path>
            <path d="M18 17V9"></path>
            <path d="M13 17V5"></path>
            <path d="M8 17v-3"></path>
          </svg>
          <span class="min-w-0 flex-1 truncate">Analytics</span>
        </a>
        <a href="#" class="flex items-center gap-3 rounded-xl px-3 py-2 text-sm font-medium transition-colors text-muted-foreground hover:bg-muted hover:text-foreground">
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-settings h-4 w-4" aria-hidden="true">
            <path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"></path>
            <circle cx="12" cy="12" r="3"></circle>
          </svg>
          <span class="min-w-0 flex-1 truncate">Settings</span>
        </a>
      </nav>
      <div class="border-t border-border/60 p-3">
        <div class="flex items-center gap-3 rounded-xl px-2 py-2">
          <span class="flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-muted text-xs font-bold">AL</span>
          <span class="min-w-0">
            <span class="block truncate text-sm font-medium">Ada Lovelace</span>
            <span class="block truncate text-xs text-muted-foreground">ada@acme.com</span>
          </span>
        </div>
      </div>
    </div>
  </aside>
  <div class="flex min-w-0 flex-1 flex-col">
    <header class="flex h-14 shrink-0 items-center gap-3 border-b border-border/60 px-4">
      <button type="button" aria-label="Open navigation" aria-expanded="false" class="rounded-lg p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground lg:hidden">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-menu h-4 w-4" aria-hidden="true">
          <path d="M4 12h16"></path>
          <path d="M4 18h16"></path>
          <path d="M4 6h16"></path>
        </svg>
      </button>
      <div class="relative max-w-xs flex-1">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-search pointer-events-none absolute start-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" aria-hidden="true">
          <path d="m21 21-4.34-4.34"></path>
          <circle cx="11" cy="11" r="8"></circle>
        </svg>
        <input type="search" placeholder="Search" aria-label="Search" class="w-full rounded-xl border border-border/60 bg-background py-1.5 ps-9 pe-3 text-sm outline-none transition-shadow placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-primary" />
      </div>
      <button type="button" aria-label="Notifications, 3 unread" class="relative ms-auto rounded-lg p-2 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-bell h-4 w-4" aria-hidden="true">
          <path d="M10.268 21a2 2 0 0 0 3.464 0"></path>
          <path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326"></path>
        </svg>
        <span aria-hidden="true" class="absolute end-1.5 top-1.5 h-2 w-2 rounded-full bg-primary ring-2 ring-background border border-transparent"></span>
      </button>
    </header>
    <main class="flex-1 overflow-y-auto p-6">
      <div class="flex h-full items-center justify-center rounded-xl border border-dashed border-border/60 text-sm text-muted-foreground">Your page content goes here</div>
    </main>
  </div>
</div>
  • This is rendered HTML, not a translation of the React source. The Tailwind classes carry the design and work in any framework.
  • It is one frame: the component in its initial state, with no props applied beyond the defaults.
  • This block is interactive in React — toggles, menus or form state. None of that survives here; the markup is the closed/default state and the handlers are gone. Re-wire them in your own framework.
  • Requires Tailwind, and the design tokens the classes reference (bg-card, text-muted-foreground, and so on). The template ZIPs ship a globals.css that defines them.

What each framework gets across the whole catalog — effects convert properly; this rung is markup.

For AI

The component, its props, the design tokens it expects and the command that installs it — as one prompt. Paste it into Claude, Cursor, v0 or ChatGPT and what they build around it will match the rest of the catalog instead of inventing its own system.

See the prompt

Used in these pages

Want the whole screen instead of this one section? Open a page and copy it entire.

8 more blocks in Dashboards

All of them free to read, copy and install — no account, no locked tiles, no watermarked preview. The whole catalog is open, and so are the API and the CLI.

Browse Dashboards

Shipping one commercially

Copying the code is free. Putting it in client work or a paid product is what Pro is for — the licence, not the access.

  • A commercial licence for everything in the catalog
  • Unlimited bundle exports, in Vue, Svelte and Tailwind
  • One payment — no subscription, nothing to renew
Pro — $79 once

More Dashboards blocks

View category
Open the full page for this block

KPI Cards With Deltas

Metric row where each card knows whether a rise is good news, so churn going up is red while revenue going up is green.

Dashboards114 lines1 dep
Open the full page for this block

Activity Feed Panel

Recent-events list with typed icons and relative timestamps that keep the absolute value in a <time> element.

Dashboards171 lines1 dep
Open the full page for this block

Kanban Board Columns

Four columns of prioritised, tagged, assigned task cards with a blocked state — the board as a layout contract, leaving drag behaviour to your own state and library.

Dashboards203 lines1 dep
Open the full page for this block

Audit Log Timeline

Events grouped by day on a vertical rail, icons varying by type and one entry expanded into a detail card — what keeps forty events scannable instead of forty gray dots.

Dashboards204 lines1 dep
Open the full page for this block

Saved View Tabs

Saved views with the third state most implementations drop: a shared view with unsaved edits, where Save changes what a colleague sees tomorrow. Two honest buttons instead of one, ownership on the tab, and dirty said in words.

Dashboards306 lines1 dep
Open the full page for this block

Comparison Period Picker

A reporting window with the comparison window spelled out beside it — resolved dates, UTC arithmetic, and an option to align weekdays so a weekend is never compared against a Tuesday.

Dashboards315 lines1 dep
Open the full page for this block

Alert Rule List

Threshold alerts with the two facts most rule lists omit: how often each has fired, and whether its channel is muted — so a rule that is on but delivering nowhere reads as its own state.

Dashboards282 lines1 dep