{% extends "base.html" %} {% import "components/macros.html" as ui %} {% block title %}Tabs & Accordions - Design System Wiki{% endblock %} {% block content %}
Horizontal tab groups and collapsible vertical headers with animated rotation chevrons, powered by lightweight document-level event delegation.
The global script components.js handles click switches for tabs via specific dataset variables. Here is the contract:
| Attribute | Type | Behavior & Purpose |
|---|---|---|
| data-tab-group | Attribute |
Applied to buttons and triggers. Isolates tab groups on the same page. Tab buttons in the same group toggle together (e.g., data-tab-group="group1").
|
| data-tab-target | Attribute |
Specifies the ID of the content element pane that should be revealed when this tab is clicked (e.g., data-tab-target="my-pane-1").
|
| data-tab-content-group | Attribute |
Applied to the content elements. Must match the data-tab-group string. Click triggers hide all content elements in this group and show the target.
|
Accordions are toggled through click delegation looking for the following class tree:
| Selector / Class | Type | Behavior & Purpose |
|---|---|---|
| .accordion-item | Class | Surrounds the single collapsible item container (trigger header + content block). |
| .accordion-trigger | Class | Clickable header button. Toggles display classes on the sibling content element. |
| .accordion-content | Class |
Contained collapsible item body text. Starts with the class hidden. Toggled by the script.
|
| .accordion-chevron | Class |
Optional vector arrow icon inside trigger. The JS applies rotate-180 animation classes on show.
|
For Tabs, you can style the tab list buttons (direction, active borders, colors) and content layout freely. Just ensure data-tab-group matches between triggers and active panes, and data-tab-target matches the pane ID.
For Accordions, you can design the headers, chevron SVGs, background panels, and borders. You must maintain the .accordion-item, .accordion-trigger, and .accordion-content class selectors so the script can toggle the collapsed state.