Docs
Navigation

Index Scrubber

An A to Z index on a glass rail that jumps through a long list as you drag, with a letter bubble that follows the finger.

$npx swiftpieces add IndexScrubber
See it in a Pro app On a real screen in one of the Pro apps: open it with Pro, take it apart, remix it, and copy the SwiftUI.
Free · MIT + Commons ClauseiOS 17.0+Liquid Glassindexalphabetsectionsscrubberjumpcontactslistscroll
Type
IndexScrubber
Files
IndexScrubber.swift
Depends on
Nothing (Apple frameworks only)
Version
1.2.0

A section index rail for long sectioned lists (contacts, glossaries, countries, recipes) that works with ScrollView, LazyVStack and List on iOS 17 and later. Touch down or drag along the rail to jump to the section under the finger. Most apps use the .indexScrubber(_:proxy:) modifier on a scroll view inside a ScrollViewReader; use the view itself when you scroll some other way, and place it on the trailing edge yourself.

Notes

  • .indexScrubber(titles, proxy: proxy) on a ScrollView or List inside a ScrollViewReader is the whole setup. Give each section an id equal to its title (ForEach(sections, id: \.title) { Section { … } }). Jumps scroll without animation, the section's top at anchor (.top by default), the way the system index does.
  • The modifier insets the scroll view's content by the rail's width (44pt at the default text size), so rows lay out beside the rail instead of under it. With no reachable sections the rail takes no space and no touches.
  • Use IndexScrubber(titles, selection: $current) { title in … } when you scroll some other way; place it on the trailing edge yourself. onSelect fires once on touch down, then only when the finger reaches a new section, plus on VoiceOver and keyboard moves.
  • index: .sections shows your titles as they are. .alphabet shows the current locale's index letters (A to Z and # in English, from UILocalizedIndexedCollation) and matches each section by its whole title, then its first character, then its first character without accents; titles starting with a digit or symbol fall under #. .custom([...]) takes your own entries.
  • Entries without a section are dimmed by default and a touch on one lands on the nearest section after it (or before it at the end). missing: .hidden leaves them out. The letter bubble and the haptic only change when the landing section changes.
  • When the rail is too short for every entry (landscape, accessibility text sizes), it shows evenly spaced entries with a dot between each, like the system index. The finger still maps proportionally along the whole column, so a dot lands on the letters it stands for and the bubble shows the real one.
  • While a finger is down the rail keeps its touch-down geometry, pinned on screen, so a jump that resizes the scroll view (a large title collapsing) never moves letters under the finger. On release it moves into its new place at once, on a short spring with no overshoot that is most of the way there in about a tenth of a second.
  • The letters sit on a clear liquid glass rail, always there, like the chrome of a tab bar. Touch down swells the rail a little either side of the letters, a signal glass bead buds out of the rail under the entry, and the letter bubble buds out of the rail beside it a beat behind: born as a drop inside the rail, it springs inward and opens to its full size, held to the rail by a liquid neck. While scrubbing the bead glides from entry to entry on a snap with a small give, the letter under it turning ink as it arrives, and the bubble rides a beat behind the bead, not the finger, its neck sliding along the rail. Its letter rolls in the direction of travel, blurring as it goes, without overshoot, like a counter. Scrubbing faster than about seven sections a second, or turning back, blurs the letter from old to new in place instead, so the bubble never smears.
  • Dragging on past either end of the column (or further out than where the finger came down, when that was in the empty rail beyond the letters), the bubble gives a little with rubber-band resistance, never as far as the next row, stretching its neck. Only the drawing goes past: the section stays the first or last, so nothing scrolls or ticks. On release the bubble narrows to a drop and melts back into the rail at its letter, its tint draining as it goes, then the bead melts in after it and the rail settles; a bubble pulled past an end draws back to its letter on the way.
  • A .selection haptic plays on touch down and on each new section, never on dimmed entries, repeated positions or the pull past an end.
  • The drag lives on the rail itself, outside the scrolling content, so it never competes with the scroll view's pan; the scroll view keeps scrolling everywhere else. A system-cancelled touch resets the rail cleanly.
  • VoiceOver: the rail is one adjustable element, "Section index", whose value is the current section. Swipe up or down to step through every section (including any the rail's entries do not reach); each step scrolls. Write selection from your own scroll tracking so it starts from the section on screen.
  • Hardware keyboard: when the rail has focus, typing a letter jumps to it, arrow keys step between sections, and Home and End go to the first and last. The rail swells while focused, and each key buds the bead and the bubble out briefly before they melt home.
  • Dynamic Type: letters, rows and the bubble scale up to the first accessibility size, then the rail collapses entries instead of growing; the bubble shows the section at display size while scrubbing. Over a dot of a collapsed rail the bead shrinks to stand for the dot.
  • Right-to-left: the rail sits on the leading edge and the bubble buds out to its inner side.
  • Reduce Motion: the bead and the bubble fade in and out where they rest instead of budding, the rail does not swell, the letter cross-fades instead of rolling, the bead and the bubble move between entries on a short spring with no overshoot, and there is no pull past the ends. The haptic and colors are unchanged. Before iOS 26 the rail, bead and bubble are frosted material with a light rim, and under Reduce Transparency they are solid.
  • Style sets the label, dimmed, bubble (the bubble's and the bead's glass tint) and ink colors. track no longer does anything, since the rail is clear glass; it stays so existing code compiles. Every letter is semibold. .disabled(true) dims the rail and ignores touches.

Usage

IndexScrubberExample()

Parameters

ParameterDescription
titlesYour section titles, in list order. They are also the values passed to onSelect, so use the same strings as the ids you scroll to. Duplicates and empty strings are ignored.
selectionThe section last jumped to. Written on every jump; write it yourself (for example from your own scroll tracking) so VoiceOver starts adjusting from the section on screen.
indexWhat the rail lists. .sections shows exactly titles; .alphabet shows the current locale's index letters (A to Z and # in English) and matches each section to a letter by its first character; .custom takes your own entries.
missingWhat happens to index entries that have no section: .dimmed keeps them in place in a quieter color (the finger lands on the nearest section after them), .hidden leaves them out.
styleColors for the letters, the letter bubble and its ink. Defaults to the SwiftPieces house palette, adapting to light and dark.
onSelectCalled with the section title to jump to: once on touch down, then each time the finger reaches a new section, and on VoiceOver or keyboard moves. Scroll without animation here, the way the system index does.

Install

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

Terminal

$npx swiftpieces add IndexScrubber

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

>Add the SwiftPieces "Index Scrubber" 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.

Explore Pro