Tab Group
lt-tab-group is the container for tabbed navigation. It coordinates lt-tab headers
with lt-tab-panel content areas. The active tab is controlled by the value prop on
the group. Keyboard navigation follows the ARIA tabs pattern: Arrow keys move between tabs, Home/End jump to
first/last, and only the active tab is in the tab order.
When no value is set, the first enabled tab is selected by default. If the tab list overflows,
scroll buttons appear automatically at either end.
Playground
Usage
<lt-tab-group value="tab1">
<lt-tab label="Overview" value="tab1" icon-start="home"></lt-tab>
<lt-tab label="Settings" value="tab2" icon-start="settings"></lt-tab>
<lt-tab label="Disabled" value="tab3" disabled></lt-tab>
<lt-tab-panel value="tab1">Overview content</lt-tab-panel>
<lt-tab-panel value="tab2">Settings content</lt-tab-panel>
</lt-tab-group>
<script type="module">
document.querySelector('lt-tab-group').addEventListener('change', (e) => {
console.log('active tab:', e.detail.value);
});
</script>
import { TabGroup, Tab, TabPanel } from '@latty-ds/react';
<TabGroup value="tab1" onChange={(e) => console.log(e.detail.value)}>
<Tab label="Overview" value="tab1" iconStart="home" />
<Tab label="Settings" value="tab2" iconStart="settings" />
<Tab label="Disabled" value="tab3" disabled />
<TabPanel value="tab1">Overview content</TabPanel>
<TabPanel value="tab2">Settings content</TabPanel>
</TabGroup>
<template>
<lt-tab-group value="tab1" @change="onTab">
<lt-tab label="Overview" value="tab1" icon-start="home"></lt-tab>
<lt-tab label="Settings" value="tab2" icon-start="settings"></lt-tab>
<lt-tab label="Disabled" value="tab3" disabled></lt-tab>
<lt-tab-panel value="tab1">Overview content</lt-tab-panel>
<lt-tab-panel value="tab2">Settings content</lt-tab-panel>
</lt-tab-group>
</template>
Manual activation
By default, arrow keys select a tab immediately (activation="automatic"). Set activation="manual" when
selection has side effects (e.g. loading data) and the user should confirm with Enter or Space before committing.
<lt-tab-group activation="manual" value="overview">
<lt-tab label="Overview" value="overview"></lt-tab>
<lt-tab label="Analytics" value="analytics"></lt-tab>
<lt-tab-panel value="overview">Overview content</lt-tab-panel>
<lt-tab-panel value="analytics">Analytics content (loaded on confirm)</lt-tab-panel>
</lt-tab-group>
Nested tab groups
Nested lt-tab-group elements are safe — inner groups' change events do
not bubble into the outer group's listeners.