Tabs & Accordion
Turns the native Tabs (Nestable) element into an accordion at the width you choose. It adds no new element: your existing tabs gain an Accordion control group.
Version: 0.2.0 · Requires: Bricks 1.9+
What it does
- Tabs when there is room, a single-open accordion when there is not. Switch by window width, by the width of the space the tabs sit in (so it works in sidebars), or always.
- Tab styling you’ve already set (title padding, background, active colours, typography) keeps working.
Installation
Upload and activate with Bricks active. Open a Tabs (Nestable) element and look under Content → Accordion.
Settings
| Setting | Options | Default |
|---|---|---|
| Switch to accordion at | Never, any Bricks breakpoint (that window width and below), Container width, a custom window width in pixels, or Always | |
| Container max width (px) | Shown for Container width. Accordion when the tabs’ parent element is this wide or narrower | 480 |
| On page load | Open the “Open tab index” panel, or all closed | First panel open |
| Always keep one panel open | On or off | Off |
| Animation | Slide or none | Slide |
| Duration | milliseconds | 250 |
| Indicator | CSS chevron on each title, or none |
Window width or container width?
The Bricks breakpoints and the custom width option compare the browser window to a width. That suits full-width layouts, but not tabs in a sidebar: on a large screen the window is wide, so the tabs would stay as tabs inside a 300px column.
Container width measures the element that holds the tabs (their parent, excluding its padding). The tabs become an accordion whenever that space is narrow, wherever it appears: a sidebar, a narrow column, an off-canvas panel or a popup. The same tabs placed in a wide column stay as tabs. It also updates live when the space resizes, not just when the window does.
- Use Container width for reusable blocks, templates and anything that can sit in a sidebar.
- Use a Bricks breakpoint when the whole page should change together at a device width.
Behaviour
- Titles and panes are re-ordered with CSS only, so the HTML and Bricks’ own tab script are untouched.
- Hover-to-open is ignored in accordion mode.
- Keyboard: Enter, Space, Up and Down on titles; Bricks’ Left, Right, Home and End still work.
- Accessibility switches between tab and accordion semantics, and reduced-motion preferences are respected.
- Fires a
bta/accordion/changedevent ondocumentwithelementId,index,open,activeTitle,activePane.
Known limits
- Borders and padding set on the Tab content wrapper don’t apply in accordion mode; style the individual Pane blocks instead.
- Breakpoint widths are read from Bricks at render time and the plugin always uses
max-width. - Container width is decided by script after the page loads, so tabs in a narrow container can appear for a moment before collapsing. Window width options are pure CSS and have no flash.
- The measured parent should not shrink to fit its content. If the parent is as narrow as its contents (some auto-width flex items), give it a width so the result is stable.