initTabs function presentation exported
Last updated: 2026-03-04T23:21:38.429Z
Location
Metrics
LOC: 19
Complexity: 6
Params: 0
Signature
initTabs(): : void
Summary
Tab navigation utility — activates/deactivates native HTML tab elements. Works with any element that has .tab and .tab-content CSS classes.
Source Code
export function initTabs(): void {
const tabs = Array.from(document.querySelectorAll<HTMLElement>(".tab"));
const contents = Array.from(
document.querySelectorAll<HTMLElement>(".tab-content"),
);
for (const tab of tabs) {
tab.addEventListener("click", () => {
for (const t of tabs) t.classList.remove("active");
for (const c of contents) c.classList.remove("active");
tab.classList.add("active");
const tabId = tab.dataset.tab;
if (!tabId) return;
const target = document.getElementById(`tab-${tabId}`);
if (target) target.classList.add("active");
});
}
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| click | dynamic_call |
Impact (Incoming)
| Source | Type |
|---|---|
| main | uses |