A course syllabus built with the Bootstrap 6 flush accordion: no outer border, only hairlines between the modules, so it sits cleanly inside a card. An "Always open" switch lets visitors choose between keeping several modules open and seeing one at a time. Expand all and Collapse all buttons sit next to it.
How it works
The list is .accordion.accordion-flush.fla-accordion, and each module is a native <details class="accordion-item"> with a <summary class="accordion-header">. The summary holds the module number .fla-num, the .fla-title, the .fla-meta lesson count and the chevron svg.accordion-icon. The body is an ordered .fla-lessons list. A CSS counter numbers the lessons, and each row ends with a monospaced .fla-time.
Bootstrap 6 makes <details> items exclusive when they share a name. script.js uses that for the mode switch:
- Always open (switch on):
applyMode()removesnamefrom every item, so any number of modules can stay open. This is the starting state, with modules 01 and 02 open. - One at a time (switch off): the script keeps only the first open module open, then gives every item the same generated name (
fla-group-1,fla-group-2, … per instance). From then on the browser closes the previous module when a new one opens.
Expand all sets open on every item and only works in always-open mode. Collapse all closes everything in both modes. A toggle listener on each <details> runs syncButtons(), which disables a button when it has nothing to do and moves keyboard focus to the other button if needed. Without JavaScript all modules can stay open.
Customization
--fla-accenton.fla-root: recolors the kicker, the open module number, the switch and the focus rings.--fla-paper,--fla-cardand--fla-lineon.fla-root: change the ruled page background, the card and the dividers.- Uncheck
#fla-alwaysin the HTML (removechecked) to start in one-at-a-time mode. - Add or remove
openon a<details>to choose which modules are expanded on load. --bs-accordion-padding-xand--bs-accordion-padding-yon.fla-accordion: make the rows roomier or tighter.- Delete
.fla-bulkif you only need the switch: the script skips the bulk buttons when they are missing.
Use cases
- Course and training pages: a syllabus lists modules that expand to show lessons
- Documentation and policies: an Always open switch toggles between multi-open and one-at-a-time
- Long content pages: Expand all and Collapse all buttons open or close every section
- Clean layouts: the flush style removes outer borders to blend into the page
Accessibility
Each header is a native <summary>, so it is focusable, toggles with Enter or Space and reports its state without ARIA. The switch uses role="switch" with a visible label and a visually hidden description that explains the mode. The bulk buttons sit in a labelled btn-group, and disabled buttons hand focus to their partner. Decorative numbers and chevrons are aria-hidden. Focus rings use the accent color, and Bootstrap skips the height animation under prefers-reduced-motion.
Bootstrap 6 notes
accordion-flush still exists, but the Bootstrap 5 Collapse markup (accordion-button, accordion-collapse, data-bs-parent) is gone. Items are <details>, and "always open" now simply means no shared name. The switch is the new .switch wrapper with a native switch attribute instead of form-switch, and the buttons are btn-outline theme-secondary. Built on Bootstrap 6.0.0-alpha.1, so APIs may still change.