Docs
Feedback

Rating Scrub

A star rating you tap or scrub: the stars fill and rise under the finger while a glass readout rides along and the label morphs.

$npx swiftpieces add RatingScrub
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 Glassratingstarsscrubgesturehapticreview
Type
RatingScrub
Files
RatingScrub.swift
Depends on
Nothing (Apple frameworks only)
Version
2.2.0

Tap-or-scrub star rating with lift, staggered settle, a score-colored fill, a liquid glass readout and an adjustable accessibility element. The stars are content and stay solid. The chrome is glass: while a finger scrubs, a readout bubble tinted with the score buds up out of the touched star, rides with the finger from star to star, and melts back down into the star the finger leaves. A tap alone never raises it, so a quick rating stays quiet.

Notes

  • Stars are soft rounded shapes that fill as solid blocks. They are the content, so they stay solid; the chrome around them is liquid glass. The block follows the score through Style.levels (the brand red, sand, butter, sage, sky by default), so a low rating reads differently from a high one at a glance. Pass tint to use one color for every score.
  • One DragGesture with zero minimum distance handles tap and scrub. The row works like soft keys: the star under the finger rises on a short spring with no overshoot, and the two stars either side of it rise a little after it, less with distance. Let go and the star you left drops first and each neighbor follows 30ms later, so the row falls back in a ripple. The lift is decoration only: the fill and numeral land on the value with no delay or overshoot, quickly under the finger and on a firm spring from VoiceOver or the binding, so a star never shows a score that isn't true.
  • While you scrub, a glass readout tinted with the score buds up out of the touched star: born behind it as a small round bubble, it rises above the lifted star while it widens to fit the rating and its label, then rides from star to star with your finger, changing tint and morphing its word as it goes. Let go and it narrows and sinks back into the star you left, its tint draining as it melts. A quick tap never raises it, so a single rating stays quiet.
  • With labels, a caption sits under the stars: a glass pill with the numeral, a dimmed decimal and "/ 5", joined by a liquid neck to a glass chip tinted with the score that carries the label for the rounded-up rating. The chip morphs its width, tint and word letter by letter as the rating changes. Unrated, the chip is clear glass reading "Tap or slide".
  • Pull past either end of the row and the end star gives a few points with rubber-band resistance, about the gap between two stars, then springs back at the speed you let go. The rating itself stays at 0 or the maximum. A scrub the system cancels, such as a scroll taking over, lets the stars and the readout go the same way.
  • Every string is semibold, so size and color carry the hierarchy. Before iOS 26 the readout, pill and chip draw on a frosted material with a light rim, and the pill and chip sit side by side without a neck. Under Reduce Transparency they are solid.
  • Reduce Motion: nothing rises, ripples or gives past the ends. The star under the finger shifts a shade in place instead (deeper in light mode, lighter in dark), the readout fades in and out above it at full width, the words crossfade, and the haptics and colors are unchanged.
  • Haptics: .selection on each step, a rigid impact when the value hits 0 or the maximum.
  • isReadOnly removes the gesture, the readout and the VoiceOver adjustable action but keeps the value readable; its chip reads "No rating" until there is one. size scales with Dynamic Type.

Usage

RatingScrubExample()

Parameters

ParameterDescription
ratingBound value from 0 to count, in whole or half steps.
countNumber of stars.
allowsHalfSnap to half stars.
labelsOptional one label per star ("Poor" ... "Great"). Adds a caption under the stars: a glass pill with the numeral, joined to a glass chip tinted with the score that carries the label for the rounded-up rating. The scrub readout shows the label too.
isReadOnlyShows the value without a gesture or adjustable action.
sizeStar point size; scales with Dynamic Type.
tintOverrides the fill color for every score. Defaults to style.levels, one block per score.
styleFill colors per score, the empty star color and text colors. .standard runs the brand red, sand, butter, sage, sky.

Install

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

Terminal

$npx swiftpieces add RatingScrub

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

>Add the SwiftPieces "Rating Scrub" 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 feedback →

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