Skip to content

Tabs

Accessible tabs with ARIA wiring, roving focus, orientation, and automatic or manual activation.

<pe-tabs class="Tabs">
<div class="List" data-tabs-list aria-label="Account settings">
  <button type="button" class="Tab" data-tabs-trigger="profile">Profile</button>
  <button type="button" class="Tab" data-tabs-trigger="security">Security</button>
  <span class="Indicator" data-tabs-indicator></span>
</div>

<section class="Panel" data-tabs-content="profile">Profile settings</section>
<section class="Panel" data-tabs-content="security">Security settings</section>
</pe-tabs>

Tabs let users switch between multiple pieces of content, showing one at a time. Give the list an accessible name and use the same non-empty value for each trigger/panel pair. Use manual activation when loading a panel is expensive or delayed.

Key Behavior
Left / Right Move through horizontal tabs, wrapping at the ends
Up / Down Move through vertical tabs, wrapping at the ends
Home / End Move to the first / last enabled tab
Enter / Space Activate the focused tab in manual mode

Disabled triggers are skipped. Prefer native disabled on buttons.

Part Selector Role
Host <pe-tabs> Lifecycle and selected-value boundary
List [data-tabs-list] Receives role="tablist" and orientation
Trigger [data-tabs-trigger="value"] Receives tab ARIA, roving tabindex, and state
Panel [data-tabs-content="value"] Receives tabpanel ARIA and hidden state
Indicator [data-tabs-indicator] Optional visual marker positioned with CSS variables
NameDescription
data-tabs-valueInitial and current selected value. Updating it selects the matching enabled tab.
data-tabs-orientation"horizontal" (default) or "vertical". Controls ARIA and arrow keys.
data-tabs-activation"automatic" (default) or "manual".
data-tabs-loop"true" (default) or "false". Controls arrow-key wrapping.
NameTypeDescription
valuestring | nullGets the current value. Assign a string to select it.
select(value, options?)voidSelects an enabled tab. Pass { focus: true } to focus its trigger.
NameDescription
pe-tabs:changeBubbles and is composed. Fired when the selected tab changes.

Event detail fields:

NameDescription
valueNew selected value, or null when none.
previousValuePrevious selected value.
triggerActivating tab trigger, when applicable.
panelMatching tab panel, when applicable.
reason"click", "keyboard", "programmatic", "attribute", "disabled", or "missing".
activationDirection"left", "right", "up", "down", or "none".
NameDescription
data-stateOn triggers and panels: "active" or "inactive". On the host: reflects the current value.
data-activation-directionOn the host and active trigger: "left", "right", "up", "down", or "none".
data-tabs-indicatorOptional visual marker inside the tab list. Receives positioning CSS variables.

When [data-tabs-indicator] is present, the component sets:

NameDescription
--active-tab-leftDistance from the list's left edge.
--active-tab-rightDistance from the list's right edge.
--active-tab-topDistance from the list's top edge.
--active-tab-bottomDistance from the list's bottom edge.
--active-tab-widthActive trigger width.
--active-tab-heightActive trigger height.