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()ordisable()on eachTooltipinstance, so tooltips appear only in the rail state. - It updates the toggle's
aria-expandedandaria-label, because Toggler does not. - It saves the choice in
localStorageinside 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-accentand--cis-accent-softon.cis-root: the active link, logo gradient, icons and focus ring.--cis-wideand--cis-railon.cis-root: the expanded width (240px) and the icon rail width (76px).--cis-speedon.cis-root: the duration of the collapse animation.--cis-glasson.cis-root: the translucent panel color behind the sidebar and cards. Change theradial-gradientlayers on.cis-rootfor another backdrop.- Change
data-bs-titleon each link to set its tooltip text, anddata-bs-placementto move the tooltip. - Add
cis-collapsedto.cis-sidein the HTML to start collapsed (a saved choice still wins on wide screens). - Rename
STORE_KEYinscript.jsif you have several apps on one domain. With several sidebars on one page, give each.cis-sideits ownidand matchingdata-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.