Docs
Navigation

Tracking Tabs

Tabs on a glass track over paging content, with a tinted indicator that rides the scroll and title ink that turns under its edge.

$npx swiftpieces add TrackingTabs
Try it in the Playground Use it on a real screen, take it apart, remix it, and copy the SwiftUI. No account needed.
Free · MIT + Commons ClauseiOS 17.0+Liquid Glasstabspagersegmentedscrollnavigationcounts
Type
TrackingTabs
Files
TrackingTabs.swift
Depends on
Nothing (Apple frameworks only)
Version
2.2.0
In a full screen · SwiftPieces ProLessonsA language-learning home with a streak, today's goals as color blocks and a floating tab bar whose lens follows your finger.

Tab bar on a liquid glass track with a scroll-linked, tinted glass indicator driving horizontally paged content. The track and the indicator are one liquid control: the indicator is a tinted glass capsule resting inside the clear glass track, in the same liquid group, and the titles sit on both.

Notes

  • Pages live in a horizontal ScrollView with .scrollTargetBehavior(.paging) and containerRelativeFrame, so each page is exactly one container wide. selection is synced with scrollPosition(id:) in both directions: a tap, or a change to selection from outside, lands the page on a spring with no overshoot, like native paging, so the pager never shows past its last page, and the pager fits the new page's height on that same spring, so both arrive as one move.
  • The titles sit on a clear liquid glass track, and the indicator is a signal-tinted glass capsule inside it, in the same liquid. It is positioned from fractional page progress (contentOffset.x / containerSize.width via onScrollGeometryChange on iOS 18, the page row's position in the .scrollView space on iOS 17), interpolated between measured title frames. Under a swipe it is a pure function of the scroll, coupled to the pages like a carriage on a rod: it follows them with no lag of its own, carries a flick's deceleration and lands where they land. While it travels it swells a couple of points, staying inside the track, and it settles flat on a title. A tap that jumps several pages keeps it swollen over the titles it passes, so it only settles where it lands. Coming in from a tap or an outside change it has a little give: it carries a couple of points past its title and snaps back while the page lands flat.
  • Each title is drawn twice, muted and ink, each cut by the indicator's outline, so the text turns ink exactly where the glass covers it and stays muted outside it. Optional counts show a monospaced count after each title and roll with .numericText. Every title and count is semibold.
  • States: resting, swiping (indicator between titles, swollen), pressed (the title sinks a couple of points; pressing the selected title sinks the indicator with it), and a .selection tick each time selection changes, from a tap or a swipe.
  • Style sets indicator (its glass tint), title, and selectedTitle; .standard is a signal indicator with house ink on it and muted titles on the clear track. track no longer does anything, since the track is clear glass; it stays so existing code compiles.
  • Titles are buttons with selected traits and their count as the value; 44 pt tall. Under Reduce Motion a tap lands the page and the indicator on a short spring with no overshoot, the indicator keeps its size while it travels, and a pressed title shades instead of sinking (darker in light mode, lighter in dark) while the indicator stays put. The indicator and the ink still follow your swipe, and the tick still plays. Before iOS 26 the track and indicator are frosted material with a light rim, and under Reduce Transparency they are solid.
  • A floating tab bar with a lens that stretches toward the finger ships in SwiftPieces Pro (lens-tab-bar).

Usage

TrackingTabsExample().preferredColorScheme(.light)

Parameters

ParameterDescription
titlesOne title per page, in order.
selectionIndex of the settled page. Tapping a title and swiping the pages both update it.
countsOptional count per page shown after its title, such as open tasks. Pass an empty array to hide counts. Defaults to none.
styleIndicator and title colors. Defaults to .standard, the house palette with a signal indicator.
pageBuilds the page for a given index. Pages fill the container width.

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add TrackingTabs

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Tracking Tabs" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All navigation →

Build it yourself: SwiftUI animations guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

54 screens · 46 patterns · 48 flows · 12 templates · 31 Build Kit skills

Explore Pro