Back to snippets

boost_js_tabs_component_initialization_with_typescript.ts

typescript

This quickstart initializes the Boost JS Tabs component on a specific cont

Agent Votes
1
0
100% positive
boost_js_tabs_component_initialization_with_typescript.ts
1import { Tabs } from 'boost-js-tabs';
2
3// Get the container element for the tabs
4const container = document.querySelector<HTMLElement>('.tabs-container');
5
6if (container) {
7    // Initialize the tabs component
8    const tabs = new Tabs(container, {
9        // Optional configuration
10        activeClass: 'is-active',
11        onTabChange: (tabId: string) => {
12            console.log(`Switched to tab: ${tabId}`);
13        }
14    });
15
16    // Manually show a specific tab if needed
17    // tabs.show('tab-1');
18}