Skip to content

feat(TabList): carousel overflow with arrow navigation - #1978

Merged
cixzhang merged 3 commits into
mainfrom
navi/feat/tablist-carousel
May 2, 2026
Merged

feat(TabList): carousel overflow with arrow navigation#1978
cixzhang merged 3 commits into
mainfrom
navi/feat/tablist-carousel

Conversation

@cixzhang

@cixzhang cixzhang commented May 2, 2026

Copy link
Copy Markdown
Contributor

Summary

When tabs overflow the container width, XDSTabList now shows carousel-style arrow buttons at the edges for horizontal scrolling. Each tab retains its intrinsic width from its label — no truncation or equal sizing.

Changes

XDSTabList.tsx

  • Added max-width: 100% wrapper so the tab list respects its parent container
  • When content overflows, left/right chevron buttons appear at the edges
  • Gradient fade masks indicate more content in either direction
  • Scrolls ~75% of visible width per click, smooth behavior
  • Non-overflow tab lists render identically to before (arrows hidden with width: 0)
  • Uses existing useScrollOverflow hook for overflow detection
  • Structure: outer <div> wraps [prev button] + <nav> scroller + [next button]

XDSTabList.test.tsx

  • Added ResizeObserver mock (needed since useScrollOverflow uses it)

TabList.stories.tsx

  • Added Overflow story: 9 tabs in a 400px container
  • Added OverflowWithDivider story: 6 tabs in a 350px container with divider

Notes

This is a draft prototype — things to consider before graduating:

  • Keyboard navigation (arrow keys to scroll?)
  • RTL support (useScrollOverflow already handles scrollLeft direction)
  • Whether the buttons should use the Layer/popover overlay pattern like Carousel does
  • Scroll-into-view when selecting a tab that's off-screen

@vercel

vercel Bot commented May 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
xds-sandbox Ready Ready Preview, Comment May 2, 2026 11:52pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label May 2, 2026
@github-actions

github-actions Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@xds/core 17.6KB 27.3KB 4.1KB

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

cixzhang added 3 commits May 2, 2026 23:47
Compose XDSCarousel inside XDSTabList for overflow scenarios instead
of reimplementing scroll logic. Carousel already handles fade masks,
arrow buttons, and smooth scrolling.

Changes:
- XDSTab: add white-space: nowrap to prevent label line wrapping
- XDSTabList: add max-width: 100% so it respects container bounds
- Stories: add Overflow and OverflowWithDivider examples using
  XDSCarousel as a child of XDSTabList
Carousel root had no width/overflow constraint, so inside a flex
parent (like XDSTabList nav) the scroller never triggered overflow —
content just pushed the container wider.

Added min-width: 0, max-width: 100%, overflow: hidden on the
Carousel root so the scroller can actually scroll. Also added
min-width: 0 on TabList nav for the same flex-shrink reason.
overflow: hidden clips vertically too, hiding the tab underline
indicator that sits at bottom: -2px. overflow-x: hidden constrains
width without clipping vertical content.
@cixzhang
cixzhang force-pushed the navi/feat/tablist-carousel branch from 659da14 to b1e5b62 Compare May 2, 2026 23:50
@cixzhang
cixzhang marked this pull request as ready for review May 2, 2026 23:51
@cixzhang
cixzhang enabled auto-merge (squash) May 2, 2026 23:51
@cixzhang
cixzhang merged commit aea90a3 into main May 2, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant