StealThis .dev

Sidebar Admin

Collapsible admin sidebar with icon-only mode, grouped navigation sections, active state, and mobile overlay. No dependencies.

Open in Lab
css vanilla-js
Targets: JS HTML

Code

A production-ready collapsible admin sidebar with icon-only compact mode, grouped navigation sections, tooltips in icon mode, mobile overlay, and smooth transitions.

Features

  • Collapses to icon-only strip (260px → 64px) with CSS transitions
  • Tooltip labels appear on hover in collapsed mode
  • Grouped sections with dividers and labels
  • Active item highlighting with left-accent indicator
  • Mobile: hidden off-screen, hamburger button slides it in with overlay backdrop
  • Bottom user profile block with avatar and role

How it works

  1. Toggle button sets .collapsed class on <aside> — CSS handles width and label visibility
  2. In collapsed mode, [data-tooltip] attribute + CSS ::after pseudo-element shows labels on hover
  3. Mobile breakpoint (≤768px) switches to overlay mode — sidebar uses transform: translateX
  4. Overlay backdrop click closes the sidebar

Accessibility

  • <nav> landmark with aria-label
  • Collapse button has aria-expanded and aria-label
  • Active item uses aria-current="page"