Docs
Inputs

Filter Rail

A scrolling rail of glass filter chips for one pick or many, with a red puck that stretches between chips and a Clear chip.

$npx swiftpieces add FilterRail
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 Glasschipsfilterscrollselectionindicator
Type
FilterRail
Files
FilterRail.swift
Depends on
Nothing (Apple frameworks only)
Version
2.2.0
In a full screen · SwiftPieces ProSearchA search screen with recent items and quick actions, and a fuzzy command palette with hold-and-slide to run.

Horizontal rail of liquid glass chips bound to a Set of selected titles. The chips are glass bubbles resting apart. Single-select marks the pick with a tinted glass puck that stretches between chips and melts into each one it crosses; multi-select tints each pick, and a Clear chip buds out of the first pick to clear them all.

Notes

  • Every chip is a liquid glass capsule. Chips are separate choices, so they rest apart, outside the distance at which glass melts together, and only goo while something crosses or buds from them.
  • Single-select marks the pick with one glass puck tinted Style.indicator, the brand red by default. At rest the selected chip carries the tint itself, so it moves with the chip through any layout change, such as counts refreshing. On a new pick the puck lifts off and travels edge by edge: the edge facing the new chip leads on a snap spring and the far edge follows a beat later on a slightly looser one, so the puck stretches toward the pick (by about an eighth of the jump) and gathers in on it, melting into each chip it crosses on the way. The edges move in points, so the pace stays even across chips of different widths. It lands with a little give, each edge a few percent of the jump past its mark, and settles without wobbling, and a pick made while it is still landing retargets it smoothly. At the first or last chip the rail's end stops the leading edge, so the puck squashes against the end with its round cap intact. Once the far edge settles, the new chip takes the tint back. Tapping the selected chip again keeps it selected, so include an "All" option if you need a neutral state.
  • While the puck travels, every label is drawn twice, in the chip's ink outside the puck and in Style.onIndicator inside it, so a label turns exactly under the puck's edge as it passes instead of crossfading. If a Set with several titles reaches a single-select rail, the puck sits on the first of them in options order.
  • Multi-select tints each picked chip's glass and blurs a check into it. The tint comes on as the press springs back, so a pick clicks on in one motion. Tints come from Style.blocks by option position, so a chip keeps its color wherever it moves; the house palette is the one brand red, since a pick is a selection. Picks file to the leading edge first and the rest of the chips make room a beat after. A chip that travels far can carry its give a little into the gap as it lands, and slips under its neighbor rather than over: a new pick under the chip before it, a deselected chip under the chip after it.
  • The first pick buds a glass Clear chip out of the leading end of the first chip, into room the rail opens for it, with a count of the picks that rolls as it changes. Clearing lets every pick go together and the Clear chip melts back into the chip that slides to the front as the room closes.
  • counts adds a result count after each title; VoiceOver reads it as the chip's value.
  • Selection changes set scrollPosition(id:), so the chosen chip centers itself (single) or the rail returns to its leading edge (multi). The scroll follows a beat behind on a calmer spring, so it never stacks with the puck into one lurch.
  • Edge fades are computed from the content frame in a named coordinate space, so they show only on the side that actually has chips hidden. The rail keeps a 44pt row; the glass's shadows draw above and below it uncut, so give it room in a tight stack.
  • Chips use the shared press: they sink a few points on touch-down with no bounce and spring back on release. Pressing the selected chip sinks the puck and its ink with it. All text is semibold. .disabled(true) dims the whole rail. One selection haptic fires for every change to the bound set, including changes made from outside.
  • Under Reduce Motion the puck slides on a short spring with no overshoot and no stretch, the scroll follows on that same short spring, the check fades and the Clear chip opens and closes in place instead of budding, and a pressed chip (or the puck) shades instead of sinking. The ink handover, the tints and the haptic stay. Reduce Transparency draws the glass as solid shapes.
  • For a searchable list of commands instead of a rail, see the Command Palette screen in SwiftPieces Pro.

Usage

FilterRailExample()

Parameters

ParameterDescription
optionsChip titles, in order.
selectionSelected titles. Single-select keeps exactly one once anything is chosen.
allowsMultipleAllow several chips at once. Selected chips move to the leading edge and a Clear chip buds out of the first.
countsOptional result count per title, shown after the chip title and read by VoiceOver.
styleColors and chip height. Defaults to the SwiftPieces house palette, adapting to light and dark.

Install

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

Terminal

$npx swiftpieces add FilterRail

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

>Add the SwiftPieces "Filter Rail" 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 inputs and forms →

Build it yourself: SwiftUI haptics 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