Tabs

Switch between related panels while preserving their content and state.

Usage

<script type="module" src="/assets/components/tabs/qds-tabs.js"></script>
<qds-tabs id="tabs-auto" label="Report sections"><qds-tab value="summary">Summary</qds-tab><qds-tab value="history" disabled>History (unavailable)</qds-tab><qds-tab value="details">Details</qds-tab><qds-tab-panel value="summary"><label>Retained draft <input value="Quarterly report"></label></qds-tab-panel><qds-tab-panel value="history">History</qds-tab-panel><qds-tab-panel value="details">Detailed operating results</qds-tab-panel></qds-tabs>

API and behavior

API Contract
value Selected string identity; first enabled tab is the fallback. Property reads the effective selection.
activation automatic (default) selects as arrow focus moves; manual waits for Enter/Space.
orientation horizontal (default) or vertical.
label Accessible name for the tablist.
qds-tab Public child with value, disabled, and a default label slot.
qds-tab-panel Public child with matching value and default content slot.

Keep tabs and panels as direct children with unique, matching values. Children automatically assign their named slots. Omitting values pairs by index; explicit values are preferable for dynamic lists. Standalone qds-tabs.js also registers both child elements. The children can be imported from tabs/qds-tab.js and tabs/qds-tab-panel.js.

The selected tab has tabindex=0; arrows wrap and skip disabled items. Home/End move to the first/last enabled tab. Vertical lists use Up/Down; horizontal lists use Left/Right, reversed in RTL. Manual activation preserves selection while focus moves. Disabled items cannot be selected. Panels stay mounted and hidden panels leave the accessibility tree. Panels have tabindex=0; set a panel’s tabindex to -1 when its first meaningful content is already focusable.

User selection dispatches bubbling/composed qds-change with { component, value, previousValue }. Programmatic values and fallback changes are silent. CSS parts: tablist on tabs, label on tab, content on panel. Do not nest buttons or links within a tab label.

Themes, lifecycle and integration

The component uses native Web Components with an open shadow root, existing QDS CSS custom properties, and no framework runtime. Base CSS is loaded once. Set data-theme="dark" or data-theme="light" on a containing element or use the documentation toolbar. Event listeners and observers are removed on disconnect; reconnecting is supported.

Interactive demo · P0 contracts and verification

Generated Quangular wrappers expose the same attributes/properties and events using the q-qds- prefix. For child composition, use the documented native child elements inside the wrapper when the native parent requires direct children. See the Quangular catalog for generated type signatures.