initTabs function presentation exported

Last updated: 2026-03-04T23:21:38.429Z

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)

graph LR initTabs["initTabs"] style initTabs fill:#dbeafe,stroke:#2563eb,stroke-width:2px click initTabs "6bdc83262fb46fde.html"
TargetType
click dynamic_call

Impact (Incoming)

graph LR initTabs["initTabs"] main["main"] main -->|uses| initTabs style initTabs fill:#dbeafe,stroke:#2563eb,stroke-width:2px click initTabs "6bdc83262fb46fde.html" click main "14348c66c1e5604a.html"
SourceType
main uses