Tabs <l-tabs>
Tabs organize content into panels, showing one at a time. Progressive enhancement — plain HTML is enhanced with ARIA roles, keyboard navigation, and an animated indicator.
<l-tabs>Options
Enclosed variant
Add variant="enclosed" for a pill-shaped tablist with a sliding background indicator.
Code
<l-tabs variant="enclosed">
<div>
<button name="account">Account</button>
<button name="password">Password</button>
<button name="notifications">Notifications</button>
</div>
<div class="p-4 text-sm text-secondary">Make changes to your account here.</div>
<div class="p-4 text-sm text-secondary">Change your password here.</div>
<div class="p-4 text-sm text-secondary">Manage your notification preferences.</div>
</l-tabs>Line variant
Add variant="line" for a tablist with a sliding underline indicator.
Code
<l-tabs variant="line">
<div>
<button name="account">Account</button>
<button name="password">Password</button>
<button name="notifications">Notifications</button>
</div>
<div class="p-4 text-sm text-secondary">Make changes to your account here.</div>
<div class="p-4 text-sm text-secondary">Change your password here.</div>
<div class="p-4 text-sm text-secondary">Manage your notification preferences.</div>
</l-tabs>Restyle the active underline and the static bottom border with --indicator-color, --indicator-thickness, --track-color and --track-thickness.
Code
<l-tabs
variant="line"
style="
--indicator-color: var(--l-color-bg-fill-info-strong);
--indicator-thickness: 3px;
--track-color: var(--l-color-divider);
"
>
<div>
<button name="overview">Overview</button>
<button name="analytics">Analytics</button>
<button name="reports">Reports</button>
</div>
<div class="p-4 text-sm text-secondary">High-level overview.</div>
<div class="p-4 text-sm text-secondary">Traffic and engagement analytics.</div>
<div class="p-4 text-sm text-secondary">Exported reports.</div>
</l-tabs>Full width
Add full-width to stretch tabs across the container.
Code
<l-tabs
variant="enclosed"
full-width
>
<div>
<button name="account">Account</button>
<button name="password">Password</button>
<button name="notifications">Notifications</button>
</div>
<div class="p-4 text-sm text-secondary">Make changes to your account here.</div>
<div class="p-4 text-sm text-secondary">Change your password here.</div>
<div class="p-4 text-sm text-secondary">Manage your notification preferences.</div>
</l-tabs>Default active tab
Set value="1" to activate a specific tab on load (0-based index).
Code
<l-tabs
variant="enclosed"
value="1"
>
<div>
<button name="account">Account</button>
<button name="password">Password</button>
<button name="notifications">Notifications</button>
</div>
<div class="p-4 text-sm text-secondary">Make changes to your account here.</div>
<div class="p-4 text-sm text-secondary">Change your password here.</div>
<div class="p-4 text-sm text-secondary">Manage your notification preferences.</div>
</l-tabs>Accessibility
Criteria
- Role
First child div gets
role="tablist", buttons getrole="tab", remaining divs getrole="tabpanel"WCAG4.1.2RGAA7.1- Linked controls
Each tab has
aria-controlspointing to its panel; each panel hasaria-labelledbypointing back to its tabWCAG1.3.1- Selection state
Active tab has
aria-selected="true"; inactive tabs havearia-selected="false"WCAG4.1.2- Focus management
Roving tabindex — active tab has
tabindex="0", otherstabindex="-1". Panels havetabindex="0"for keyboard accessWCAG2.1.1RGAA12.13- Hidden content
Inactive panels use the
hiddenattributeWCAG1.3.2- Motion
Indicator animation respects
prefers-reduced-motionWCAG2.3.3
Keyboard interactions
API reference
Importing
import 'luxen-ui/tabs';@import 'luxen-ui/css/tabs/enclosed';@import 'luxen-ui/css/tabs/line';Attributes & Properties
variantTabsVariantdefault:'line'Property- Visual variant.
valuestringdefault:'0'Property- Index of the active tab (0-based).
full-widthbooleandefault:falseProperty- Stretch tabs to fill container width.
orientationTabsOrientationdefault:'horizontal'Property- Tab orientation.
Events
changeEvent- Fired when the active tab changes. Detail:
{ index: number, name: string | null }.
CSS custom properties
--indicator-colordefault:var(--l-color-text-primary)Custom propertylinevariant: color of the active underline that slides under the selected tab.--indicator-thicknessdefault:2pxCustom propertylinevariant: thickness of the active underline.--track-colordefault:var(--l-color-border)Custom propertylinevariant: color of the static bottom border the tabs sit on.--track-thicknessdefault:1pxCustom propertylinevariant: thickness of the static bottom border.