Vertical Sidebar

Navigation
Layout

Side navigation with collapsible sections, badges, and user profile footer.

Preview

A flexible sidebar navigation with main and secondary sections

AI Right Sidebar

Companion sidebar for AI assistance

See it with AI Assistant

Want to see how the Vertical Sidebar works alongside an AI Assistant panel? Check out the AI Right Sidebar page for a live 3-column layout demo!

View AI Right Sidebar Demo

Props

Component API reference

PropTypeDefaultDescription
items*NavItem[]Main navigation items
secondaryItemsNavItem[]Secondary navigation items
collapsedbooleanfalseCollapsed state
onCollapsedChange(collapsed: boolean) => voidCollapse toggle callback
userUserInfoUser info for footer section
logoReactNodeCustom logo component
classNamestringAdditional CSS classes

Usage

Import and implementation examples

import { useState } from 'react'
import { Home, Settings, Users, ChevronLeft, ChevronRight } from 'lucide-react'

const navItems = [
  { icon: Home, label: 'Home', href: '/' },
  { icon: Users, label: 'Team', href: '/team', count: 12 },
  { icon: Settings, label: 'Settings', href: '/settings' },
]

function Sidebar() {
  const [collapsed, setCollapsed] = useState(false)
  const [active, setActive] = useState('Home')

  return (
    <aside className={`${collapsed ? 'w-16' : 'w-64'} flex flex-col h-screen`}>
      {/* Header with collapse button */}
      <div className="flex items-center justify-between p-4 border-b">
        {!collapsed && <span className="font-semibold">App Name</span>}
        <button onClick={() => setCollapsed(!collapsed)}>
          {collapsed ? <ChevronRight /> : <ChevronLeft />}
        </button>
      </div>

      {/* Navigation items */}
      <nav className="flex-1 p-3 space-y-1">
        {navItems.map((item) => (
          <button
            key={item.label}
            onClick={() => setActive(item.label)}
            className={`w-full flex items-center gap-3 px-3 py-2.5 rounded-lg ${
              active === item.label ? 'bg-indigo-50 text-indigo-600' : ''
            }`}
          >
            <item.icon className="w-5 h-5" />
            {!collapsed && <span>{item.label}</span>}
          </button>
        ))}
      </nav>

      {/* User section */}
      <div className="p-3 border-t">
        <div className="flex items-center gap-3 p-2">
          <div className="w-8 h-8 bg-indigo-500 rounded-full" />
          {!collapsed && <span>User Name</span>}
        </div>
      </div>
    </aside>
  )
}
This block is self-contained (no UI component dependencies)

Features

Built-in functionality

  • Collapsible: Toggle between expanded and icon-only modes
  • Badges & counts: Show status badges and notification counts
  • User profile: Dedicated user section at the bottom
  • Section headers: Organize nav into main and secondary sections
  • Active states: Clear visual indication of current page
  • Hover effects: Smooth transition animations
  • Custom logo: Brand identity in header
  • Dark mode: Full dark mode support

Accessibility

Accessibility considerations

ARIA Attributes

Uses aside element for semantic structurerole="navigation" for nav containeraria-current="page" for active itemaria-expanded for collapse state

Keyboard Navigation

KeyAction
TabNavigate between items
Enter/SpaceActivate item or toggle collapse

Notes

  • Collapsed state hides labels but keeps tooltips
  • Focus visible on all interactive elements
  • Screen reader announces current section