@dojo-ng/tab-container
v0.1.2
Published
Dojo NG tab-container web component
Readme
@dojo-ng/tab-container
<dj-tab-container> — Tabbed interface.
Part of Dojo NG, a framework-agnostic web component library built on Lit. BSD-3-Clause.
tabs describes the buttons; the panels are slotted children in the same order (one per tab). The active panel is shown, the rest hidden. ARIA tablist/tab/tabpanel with roving arrow/Home/End keyboard; arrows, Home and End skip disabled tabs. Delete closes a closeable tab (the tab advertises it with aria-keyshortcuts); its close icon is for the pointer only, so no button sits inside a tab. If active-index points at no tab or a disabled one, the first enabled tab keeps the Tab-key stop. Each tab controls its panel (aria-controls, where the browser supports element references) and each panel is labelled with its tab's name unless it has its own label. Inactive panels stay hidden even when page CSS sets their display. Local coordination of slotted panels — no store needed.
Install
npm install @dojo-ng/tab-containerUsage
Import the package to register the custom element, then use the tag.
Provide tabs; slot one panel per tab in order.
<dj-tab-container id="tabs">
<div>Panel A</div>
<div>Panel B</div>
</dj-tab-container>
<script type="module">
import "@dojo-ng/tab-container";
document.getElementById("tabs").tabs = [{ name: "A" }, { name: "B" }];
</script>Properties
↻ marks an attribute reflected to the DOM; a dash means the property is set in JavaScript only.
| Property | Attribute | Type | Default |
|---|---|---|---|
| tabs | tabs | TabItem[] | [] |
| activeIndex | active-index ↻ | number | 0 |
| alignButtons | align-buttons ↻ | "top" \| "bottom" \| "left" \| "right" | "top" |
Slots
- default slot
CSS parts
tablisttabpanels
Events
change: Detail: active index.dj-tab-close: Detail: index.
Theming
Styled with Dojo NG --dj-* design tokens and exposes ::part() hooks for targeted overrides.
Accessibility and i18n
Follows the project's WCAG 2.2 AA and localization conventions.
More
Live, interactive examples are at play.dojo-ng.com. For the full API reference, theming, accessibility, and localization guides, see the Dojo NG documentation.
