Skip to content

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.

Also known as: collapsible sidebar, icon sidebar, mini sidebar, sidebar icon rail, collapsed sidebar with tooltips

Collapsible Icon Sidebar live demo

Open in new tab

Bootstrap 6 code (HTML, CSS, JS)

A light, glass-style Bootstrap 6 sidebar that collapses from a full menu into a slim icon rail. While it is collapsed, every icon shows its name in a Bootstrap tooltip. It suits project tools, note apps and dashboards that need room for content.

How it works

The <aside class="cis-side" id="cis-side"> carries data-bs-attribute="class" and data-bs-value="cis-collapsed". The .cis-toggle button uses Bootstrap 6's new Toggler component (data-bs-toggle="toggler" with data-bs-target="#cis-side"). Each click adds or removes cis-collapsed on the sidebar, with no custom click handler. CSS then animates width from --cis-wide to --cis-rail, rotates the chevron and hides every .cis-label. The labels are clipped, not removed, so screen readers still hear them. The unread badge shrinks into a corner dot.

Every link has data-bs-toggle="tooltip", data-bs-placement="right" and a data-bs-title. script.js listens for toggled.bs.toggler on the sidebar. On each change it does three things:

  • It calls enable() or disable() on each Tooltip instance, so tooltips appear only in the rail state.
  • It updates the toggle's aria-expanded and aria-label, because Toggler does not.
  • It saves the choice in localStorage inside try/catch, so it fails quietly in sandboxed previews.

On load the saved state is restored. .cis-ready is added after the first paint, so the sidebar does not animate on page load.

Below 768 px the sidebar always starts as a rail. When expanded, it floats over the content as an overlay. Escape or picking a link collapses it again.

Customization

  • --cis-accent and --cis-accent-soft on .cis-root: the active link, logo gradient, icons and focus ring.
  • --cis-wide and --cis-rail on .cis-root: the expanded width (240px) and the icon rail width (76px).
  • --cis-speed on .cis-root: the duration of the collapse animation.
  • --cis-glass on .cis-root: the translucent panel color behind the sidebar and cards. Change the radial-gradient layers on .cis-root for another backdrop.
  • Change data-bs-title on each link to set its tooltip text, and data-bs-placement to move the tooltip.
  • Add cis-collapsed to .cis-side in the HTML to start collapsed (a saved choice still wins on wide screens).
  • Rename STORE_KEY in script.js if you have several apps on one domain. With several sidebars on one page, give each .cis-side its own id and matching data-bs-target.

Use cases

  • Dashboards with limited space: the sidebar collapses to an icon rail to give content more room
  • Analytics and CRM apps: tooltips name each icon while the sidebar is collapsed
  • Returning users: the sidebar remembers its collapsed or expanded state
  • Modern light interfaces: a glass-style panel fits clean, minimal app layouts

Accessibility

The sidebar is an <aside> with a labelled <nav>. The toggle exposes aria-expanded and aria-controls, and its label switches between "Collapse sidebar" and "Expand sidebar". The current page uses aria-current="page". Hidden labels keep each link's accessible name, and tooltips also open on keyboard focus. All controls have a visible focus ring, and transitions are turned off under prefers-reduced-motion.

Bootstrap 6 notes

Toggler is new in Bootstrap 6. It replaces the small custom class-toggle scripts that Bootstrap 5 projects needed. Tooltips now initialise on their own on first hover or focus, so the BS5 new bootstrap.Tooltip() loop is gone. Here the script only imports Tooltip to enable and disable the instances. The user chip uses the new .avatar and .avatar-status classes. Built on Bootstrap 6.0.0-alpha.1, so APIs may still change.

Collapsible Icon Sidebar 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
Category
Sidebars
License
Free for personal and commercial use

Questions about this template

Can I use the Collapsible Icon Sidebar 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.

Collapsible Icon Sidebar – free Bootstrap 6 sidebar template
Collapsible Icon Sidebar · 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.

Admin Sidebar with Collapsible Menu – free Bootstrap 6 sidebar template

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.

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.