Tabs

Tabs

Two highlights on one row of tabs. The selected fill moves on click, and a lighter one follows the pointer.

Spring catalogue

Nine prints, two waiting for review. The next proof ships on Friday.
import { createMovingHighlight } from "@reuse-sh/interactions";

const tabs = document.querySelector('[role="tablist"]');
// The selected fill moves only when aria-selected changes.
const selected = createMovingHighlight(tabs, {
  rowSelector: '[role="tab"]',
  selectedSelector: '[aria-selected="true"]',
  mode: "selected",
  className: "tab-selected",
});
// A lighter fill follows the pointer and never rests.
const hover = createMovingHighlight(tabs, {
  rowSelector: '[role="tab"]',
  selectedSelector: "[data-none]",
  className: "tab-hover",
});