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.activeto 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-expandedonshown.bs.drawerandhidden.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-bgand--asc-side-bg-2on.asc-root: the two colors of the sidebar gradient.--asc-accenton.asc-root: the active link tint, its indicator bar, the logo gradient and the focus ring.--asc-widthon.asc-root: the sidebar width from the md breakpoint up (268px by default).- Change
md:drawertolg:draweron.asc-side, and the@media (min-width: 768px)rule to 1024px, to keep the Drawer up to the large breakpoint. - Add
showto a.collapseand set its toggle'saria-expanded="true"to open that section by default. - Delete the
event.preventDefault()line inscript.jsso links follow their realhref. - Replace
.asc-mainwith 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.