Skip to content
Knsept
Free playbook

Sliding tabs

Accessible tabs with an indicator that glides between them. Full keyboard support, works at any width.

JavaScriptCSSUI Widgets Updated Oct 23, 2026
Live demo Reduced motion is on, so effects are toned down
<div class="tabs">
  <div class="tab-list" role="tablist" aria-label="Project views">
    <button role="tab" id="tab-overview" aria-controls="panel-overview" aria-selected="true">Overview</button>
    <button role="tab" id="tab-activity" aria-controls="panel-activity" aria-selected="false" tabindex="-1">Activity</button>
    <button role="tab" id="tab-settings" aria-controls="panel-settings" aria-selected="false" tabindex="-1">Settings</button>
    <span class="tab-indicator" aria-hidden="true"></span>
  </div>
  <div role="tabpanel" id="panel-overview" aria-labelledby="tab-overview">Everything at a glance: status, owners and the latest deploy.</div>
  <div role="tabpanel" id="panel-activity" aria-labelledby="tab-activity" hidden>Recent commits, comments and releases, newest first.</div>
  <div role="tabpanel" id="panel-settings" aria-labelledby="tab-settings" hidden>Names, access and notifications for this project.</div>
</div>

This follows the WAI-ARIA tabs pattern: only the selected tab is in the Tab order (a "roving tabindex"), the arrow keys move between tabs, Home and End jump to the ends, and each panel is labelled by its tab.

The indicator is a single element behind the tabs. JavaScript reads the active tab's offsetLeft and offsetWidth and hands them to CSS, which does the sliding. A ResizeObserver re-measures when the layout changes, so the indicator stays aligned on resize and after web fonts load.

With reduced motion on, the indicator slides in a quick 0.15s instead of the full glide.

More from the library

Navigation live

Smooth accordion

A FAQ accordion built on native details/summary, with a smooth open and close animation and an optional one-open-at-a-time mode.

Navigation live

Animated menu button

A hamburger icon that morphs into an X and opens a menu. Correct aria-expanded, Escape to close, focus handled.

Scroll & motion live

Count-up stats

Numbers that count up when they scroll into view, with easing and formatting. A quicker count with reduced motion.