Skip to content

Admin Sidebar with Collapsible Menu

Dark Bootstrap 6 admin sidebar with icons, badges and collapsible nested menu sections that turns into a Drawer on mobile, with an account menu.

Also known as: admin sidebar, collapsible sidebar menu, dashboard sidebar navigation, sidebar with submenus, mobile drawer sidebar

Admin Sidebar with Collapsible Menu live demo

Open in new tab

Bootstrap 6 code (HTML, CSS, JS)

A dark Bootstrap 6 admin sidebar with icons, count badges and collapsible menu sections that nest two levels deep (Ecommerce → Catalog → Products). It suits back-office dashboards, CMS panels and SaaS consoles. On phones the same markup becomes a slide-in Bootstrap 6 Drawer. A small light content area shows how the sidebar sits next to a page.

How it works

The sidebar is one <dialog class="drawer drawer-start md:drawer asc-side">. With md:drawer, Bootstrap 6 shows it as a static column from 768 px up. Below that it is an off-canvas Drawer opened by the .asc-open button with data-bs-toggle="drawer". data-bs-theme="dark" on the dialog keeps menus and buttons inside it dark while the page stays light.

Each section header is a button.asc-toggle with data-bs-toggle="collapse", data-bs-target and aria-expanded, and controls a .collapse wrapper around an .asc-sub list. Nesting is just a .collapse inside another .collapse. Sections that start open carry collapse show and aria-expanded="true". The chevron .asc-chev rotates through an [aria-expanded="true"] selector, because Bootstrap 6 no longer adds a .collapsed class.

script.js does three small jobs:

  • It moves aria-current="page" and .active to the clicked link and copies the label into the breadcrumb and heading of the demo content area.
  • It closes the Drawer after a click on mobile with Drawer.getOrCreateInstance(...).hide().
  • It syncs the opener's aria-expanded on shown.bs.drawer and hidden.bs.drawer, since the data API does not do that.

It also adds .asc-ready after the first paint, so sections that start open do not animate on load.

The account row at the bottom opens a Bootstrap 6 Menu with data-bs-placement="top-end".

Customization

  • --asc-side-bg and --asc-side-bg-2 on .asc-root: the two colors of the sidebar gradient.
  • --asc-accent on .asc-root: the active link tint, its indicator bar, the logo gradient and the focus ring.
  • --asc-width on .asc-root: the sidebar width from the md breakpoint up (268px by default).
  • Change md:drawer to lg:drawer on .asc-side, and the @media (min-width: 768px) rule to 1024px, to keep the Drawer up to the large breakpoint.
  • Add show to a .collapse and set its toggle's aria-expanded="true" to open that section by default.
  • Delete the event.preventDefault() line in script.js so links follow their real href.
  • Replace .asc-main with your own page content. It is only a sample.

Use cases

  • Admin panels: icons, badges and nested menu sections organize many pages
  • SaaS dashboards: collapsible groups keep the navigation short until opened
  • Mobile admin views: the sidebar turns into a drawer on small screens
  • Account access: an account menu offers profile links at the bottom of the navigation

Accessibility

The menu is a <nav aria-label="Admin"> with real lists. Section toggles are buttons with aria-expanded and aria-controls, and the current page uses aria-current="page". The Drawer is a native modal <dialog> with a labelled title, a focus trap and Escape to close, and focus returns to the opener. Links show a visible focus ring. Icons are aria-hidden, and transitions are turned off under prefers-reduced-motion.

Bootstrap 6 notes

Bootstrap 5's offcanvas-md becomes md:drawer on a <dialog>. Collapse keeps the familiar data-bs-toggle="collapse", but the .collapsed class and .collapsing are gone. dropdown-menu becomes .menu, and dropup becomes data-bs-placement="top-end". The breadcrumb uses the new breadcrumb-link and breadcrumb-divider markup. Built on Bootstrap 6.0.0-alpha.1, so APIs may still change.

Admin Sidebar with Collapsible Menu at a glance

Framework
Bootstrap 6
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 6, Bootstrap Icons
Layout
Responsive, works on mobile, dark design
Category
Sidebars
License
Free for personal and commercial use

Questions about this template

Can I use the Admin Sidebar with Collapsible Menu code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 6 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/css/bootstrap.min.css">
  • <script type="module" src="https://cdn.jsdelivr.net/npm/bootstrap@6.0.0-alpha.1/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

Built for Bootstrap 6.0.0-alpha.1. Bootstrap 6 ships as an ES module, so its script and this component's JavaScript load with type="module". Alpha releases can still change before the stable version.

Admin Sidebar with Collapsible Menu – free Bootstrap 6 sidebar template
Admin Sidebar with Collapsible Menu · free Bootstrap 6 sidebar template

More Sidebars

Icon Sidebar that Expands on Hover – free Pure CSS sidebar template

Icon Sidebar that Expands on Hover

Pure CSS icon rail that widens to reveal labels, section headings and a profile on hover or keyboard focus, with an active link and badge.

Collapsible Dashboard Sidebar – free Tailwind CSS sidebar template

Collapsible Dashboard Sidebar

Dark Tailwind CSS dashboard sidebar with icons, grouped sections, an unread badge and a button that collapses it to an icon rail with tooltips.

Collapsible Icon Sidebar – free Bootstrap 6 sidebar template

Collapsible Icon Sidebar

Light glass-style Bootstrap 6 sidebar that collapses to an icon rail with the Toggler component, shows tooltips for icons while collapsed and remembers its state.

Sidebar with Nested Collapsible Menu – free Bootstrap 5 sidebar template

Sidebar with Nested Collapsible Menu

Dark Bootstrap 5 sidebar with three-level collapsible menu groups, accordion behavior, active link highlight and an off-canvas panel on mobile.