Tiem Cong Nghe

Showing suggestions.

Opening the store's index…
↑↓ to move↵ to openesc to close
Tiem Cong Nghe search
Componentv1.0.0~4.9 KB gzipped

Animated Tabs

Tabs with a glass pill that stretches from tab to tab, and panels that slide the same way

FreeFree
Format

.zip · HTML / CSS / JS · v1.0.0

Free — no account, no email. Always the newest version.

Live preview

Version
Preview width
Zoom

About

Tabs that show where you are going. Pick a tab and a frosted-glass pill stretches across to it — the leading edge first, the trailing edge close behind — then settles on its new tab. The panels move with it: the new one slides in from the side the pill travelled to while the old one fades out.

  • Two styles: a glass pill behind the label, or a thin gradient underline
  • Horizontal or vertical; a long tab bar scrolls sideways on small screens and keeps the selected tab in view
  • Follows the layout: the indicator re-measures when the page resizes or web fonts finish loading
  • Every colour, radius and timing is a CSS custom property; the script only writes positions
  • Nothing to install: one CSS file and one small script, or one React component

Features

  • An indicator that stretches across both tabs, then settles on the new one
  • Panels cross-fade and slide in the direction of travel
  • Pill and underline styles, horizontal or vertical, light and dark
  • A long tab bar scrolls sideways and keeps the selected tab in view
  • Plain HTML/CSS/JS and React (Next.js ready) builds
  • Zero dependencies, about 5 KB gzipped

How to use it

Link the stylesheet and the script once, then mark each set of tabs with data-tabs:

HTML
<link rel="stylesheet" href="animated-tabs.css" />
<script src="animated-tabs.js" defer></script>

<div class="animated-tabs" data-tabs>
  <div class="animated-tabs__list" role="tablist" aria-label="Settings">
    <button class="animated-tabs__tab" role="tab" type="button" aria-selected="true">General</button>
    <button class="animated-tabs__tab" role="tab" type="button">Billing</button>
  </div>
  <div class="animated-tabs__panel" role="tabpanel">…</div>
  <div class="animated-tabs__panel" role="tabpanel" hidden>…</div>
</div>

Tabs pair with panels in order (or by aria-controls); the script fills in ids and the remaining ARIA attributes. Keep the panels direct children of .animated-tabs and mark all but the first hidden, so the page is right before the script runs. A tab with disabled is skipped.

Options as data attributes on the root: data-variant="underline" (default: the pill), data-orientation="vertical", data-activation="manual" (arrows move focus, Enter / Space select).

Every change fires a bubbling tabchange event, from the user or from a script:

JavaScript
document.querySelector("#settings").addEventListener("tabchange", (event) => {
  console.log(event.detail.value, event.detail.previousValue); // also .index, .previousIndex
});

AnimatedTabs.get(element).select("billing"); // by data-value (else id), or by index

Tabs added after the page loads: AnimatedTabs.init(container) — it returns a function that undoes it. AnimatedTabs.createTabs(element, { activation, orientation }) sets up one element directly.

Ask about this product

Not sure it fits your project? Ask — the answer comes from this page.

Answers are written by AI from this page and can be wrong. The page itself is what counts.

Changelog

  1. 1.0.0First releaseLatest

    Plain HTML/CSS/JS and React builds. Pill and underline styles, horizontal and vertical lists, automatic and manual activation, full keyboard and reduced-motion support.

  2. Fixes and new features land behind the same download, which always serves the latest version.

Reviews

No reviews yet

Used it? Be the first to say how it went.

Write a review

How did it work for you? Reviews appear once we have read them.

Your rating
Never shown. Only used if we need to reach you about your review.
0 / 2000

Your name and review are shown on this page; your email is not. See the terms.

  • ComponentNavigation

    Magnify Dock

    A frosted-glass dock whose icons swell under the pointer while their neighbours glide aside

    Free