Tabview
Tabview is a JavaScript-powered tab-switching component built on top of the Nav base. It pairs a .nav.is-tabview tab bar with separate .tab-content panel elements and delivers a slideUpFade entrance animation on the revealed panel alongside a smooth sliding underline indicator that tracks the active tab.
Unlike static navigation, Tabview is initialized by the Hygular runtime which automatically manages active states, panel visibility, and indicator positioning. A ResizeObserver keeps the underline correctly placed whenever the container is resized.
All Tabview interactions are powered by the Hygular runtime.
Quick reference
| Feature | Attribute / Class | Purpose |
|---|---|---|
| Tab bar | .nav.is-tabview | Activates the tab bar layout with a bottom border. |
| JS init | data-hygular="tabview" | Required. Marks the element for automatic runtime initialization. |
| Tab target | data-tab | CSS selector pointing to the controlled panel. |
| Panel | .tab-content | Content panel revealed when its tab is activated. |
| Active tab | .is-active | Marks the currently selected tab item. |
| Open panel | .is-open | Makes the panel visible and triggers the entrance animation. |
| Underline indicator | .tab-indicator | Sliding underline injected automatically by the runtime. |
| Vertical mode | .is-vertical | Switches to a left-side sliding bar indicator. |
| Border color | --tab-indicator-color | CSS custom property for the active tab "border" color. |
Getting started
Tab items use data-tab to point at their corresponding panel by CSS selector. The data-hygular="tabview" data-tab-indicator="true" attribute is required for the runtime to auto-initialize the component.
<ul class="nav is-tabview" data-hygular="tabview" data-tab-indicator="true">
<li class="nav-item" data-tab="#panel-1">Overview</li>
<li class="nav-item" data-tab="#panel-2">Details</li>
<li class="nav-item" data-tab="#panel-3">Reviews</li>
</ul>
<div id="panel-1" class="tab-content">
<p>Overview content goes here.</p>
</div>
<div id="panel-2" class="tab-content">
<p>Details content goes here.</p>
</div>
<div id="panel-3" class="tab-content">
<p>Reviews content goes here.</p>
</div>
Overview content goes here.
Details content goes here.
Reviews content goes here.
Runtime behavior
| Capability | Description |
|---|---|
Auto-init | Scans the page for all [data-hygular="tabview" data-tab-indicator="true"] elements and initializes each one as it approaches the viewport. |
First tab activation | Activates the first tab on init unless a tab already has is-active in the HTML. |
ResizeObserver | Repositions the underline indicator automatically whenever the container is resized. |
Dispose() | Disconnects the observer and frees memory when the component is removed from the DOM. |
Vertical tabview
Add is-vertical to .nav.is-tabview to switch to a vertical tab layout. The runtime detects the modifier automatically — the underline indicator becomes a --tab-indicator-size wide left-side bar that slides vertically instead of horizontally.
<ul class="nav is-tabview is-vertical" data-hygular="tabview" data-tab-indicator="true">
<li class="nav-item" data-tab="#v-panel-1">Profile</li>
<li class="nav-item" data-tab="#v-panel-2">Security</li>
<li class="nav-item" data-tab="#v-panel-3">Billing</li>
</ul>
<div id="v-panel-1" class="tab-content"><p>Profile settings.</p></div>
<div id="v-panel-2" class="tab-content"><p>Security settings.</p></div>
<div id="v-panel-3" class="tab-content"><p>Billing information.</p></div>
Profile settings.
Security settings.
Billing information.
CSS variable theming
| Variable | Default | Description |
|---|---|---|
--tab-indicator-color | var(--tab-color, var(--primary)) | Color of the generated tab indicator. |
<ul class="nav is-tabview" data-hygular="tabview" data-tab-indicator="true"
style="--tab-indicator-color: #c7d2fe;">
<li class="nav-item" data-tab="#t1">Design</li>
<li class="nav-item" data-tab="#t2">Code</li>
</ul>
<div id="t1" class="tab-content"><p>Design content.</p></div>
<div id="t2" class="tab-content"><p>Code content.</p></div>
Accessibility
Hygular Tabview assigns tab and tabpanel roles, connects labels and panels, and supports keyboard navigation.
- Use descriptive tab labels so screen readers can identify panel content.
- Avoid hiding critical content inside tabs — ensure it is reachable via keyboard navigation.
- If you do not want an indicator animation on the active tab element, set
data-tab-indicator="false"on the tab container.