Docs
Lists

Follow Scroll

A chat and feed container that stays pinned to the newest item, counting new ones into a glass pill once you scroll up to read.

$npx swiftpieces add FollowScroll
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 Glasschatfeedlogscrollauto-scrollnew-messagespaginationliquid-glass
Type
FollowScroll
Files
FollowScroll.swift
Depends on
Nothing (Apple frameworks only)
Version
1.2.0

Colors and metrics for FollowScroll. .standard is the house palette.

Notes

  • Opens on the newest item and, while the reader is within followThreshold (48pt) of the bottom, scrolls each new item into view with a short smooth scroll. Many items arriving in one update scroll once.
  • Once the reader scrolls up, new items never move the content. They are counted into a liquid glass pill at the bottom, such as "3 new", with a red dot and a down arrow. Tapping it (or ⌘↓ on a hardware keyboard) jumps to the latest and clears the count; scrolling back down by hand clears it too. Items removed before they are seen drop out of the count.
  • The pill buds out of the scroll view's bottom edge, the edge the rows slip under (the screen's bottom, or the top of a composer). Just past that edge lies a hidden glass lip: the pill is born inside it, rises through the edge pulling a liquid neck that snaps just clear of it, and settles with a small give above the safe area. When the reader is caught up it melts back down into the edge on a spring with no bounce, keeping the count it had, its label blurring away first so nothing rides it down. Each new count rolls the number and eases the pill's width without overshoot, so a busy feed never keeps it wobbling and the count never shows a number that isn't true.
  • More than three quarters of a screen above the latest with nothing new, the pill shows as a compact round jump button, and it stays until the reader is back within about 60% of a screen, so it never flickers at the line. When news arrives it changes form rather than being swapped, with a slight give: the same arrow slides over as the red dot grows in just behind it, and the count opens beside it. Turn it off with Style(showsJumpButton: false).
  • alwaysFollow jumps to the bottom for chosen items even when scrolled up. Pass \.isMine so the reader's own sent message always comes into view.
  • onReachTop loads older items when the reader nears the top (within about three quarters of a screen). Prepend them to items before it returns: the rows on screen stay exactly where they are, including when the reader is resting on the very top edge. A small glass bubble with a spinner buds down out of the top edge while it runs and melts back up into it when it is done. It never runs twice at once, it runs again while a short list still reaches the top, and a call that adds nothing is not repeated until the reader scrolls away and back, so an exhausted history or a failed request never loops.
  • Stays pinned to the bottom when the container changes size while following: the keyboard (for a composer in safeAreaInset(edge: .bottom)), rotation, or the last row growing as text streams into it. Scrolled up, the reader's place holds through all of these.
  • Replacing the whole array (another conversation, a new filter) starts again at the latest with the count cleared. Removing the newest items is not treated as a reset.
  • Only a scroll by the reader leaves the bottom: rows inserted above, lazy rows re-measuring and resizes never do. On iOS 18 and later a finger on the content also holds back any automatic scroll until the gesture ends.
  • isFollowing (optional binding) reflects whether the view is pinned, for a "Live" badge or a toolbar button; set it to true to jump to the latest.
  • empty is shown centered while there are no items. Rows are laid out in a LazyVStack, so long threads and logs stay cheap.
  • Tracking: iOS 18 and later read onScrollGeometryChange and onScrollPhaseChange; iOS 17 measures the content in the scroll view's coordinate space. Both feed the same logic, and position is held through scrollPosition(id:anchor:) on the bottom-most row.
  • Pill and spinner: Liquid Glass on iOS 26 (interactive on the pill), a frosted material with a light rim and a soft shadow earlier, and the solid Style.surface under Reduce Transparency. All text and glyphs are semibold. On iOS 26 the interactive glass gives the press; elsewhere the pill sinks slightly under the finger and springs back.
  • VoiceOver: the pill is a button read as its label ("3 new") with the hint "Jump to latest"; the scroll view offers a "Jump to latest" action while scrolled up; new items that arrive while scrolled up are announced once per burst with the final count.
  • Localization: newItemLabel gives the pill text and the announcement. The default is a localized "3 new" through String(localized:); add plural variants in your String Catalog, or pass your own. The pill mirrors in right-to-left layouts.
  • Dynamic Type: the pill and its dot scale, the label wraps to two lines at the largest sizes, and the hit area never drops below 44pt.
  • Reduce Motion: jumps are instant instead of scrolling, the pill and the spinner fade in and out in place instead of budding and melting, the red dot fades instead of growing and the arrow keeps its size, the count crossfades instead of rolling, and where the pill is not Liquid Glass a press dims it instead of sinking it. In either mode rows never pick up an animation, and the corrections that keep the bottom glued (keyboard, rotation, a growing row) and the prepend restore are instant.
  • Haptics: a light tap when the pill first appears with news, and a soft one when you jump. Nothing fires for each new item.
  • Style sets the pill's label, signal dot and ink, the Reduce Transparency surface, the spinner color, row spacing, horizontal and vertical padding, the follow threshold and whether the compact jump button shows.

Usage

FollowScrollExample()

Install

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

Terminal

$npx swiftpieces add FollowScroll

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

>Add the SwiftPieces "Follow Scroll" 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 lists →

Build it yourself: SwiftUI loading states guide · SwiftUI cards 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