Docs
Feedback

Reaction Toggle

A like or save toggle in liquid glass that floods with its tint, springs its symbol, rolls the count and buds a confirmation pill.

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

Liquid glass reaction toggle with press feel, a tint that floods the glass from the symbol, a rubbery symbol squash, and an optional rolling count and confirmation pill that buds out of the capsule.

Notes

  • At rest the toggle is a neutral liquid glass capsule. Turning it on leads with two things on the tap: the tint floods out of the symbol to the rim, showing through the glass as it spreads, and the symbol swaps to its filled form in dark ink, blurring from one to the other, and squashes like soft rubber, flattening wide, springing up tall with a small tilt and wobbling to rest. Two beats (140 ms) later the glass takes the tint as its own, so at rest the capsule is tinted glass rather than a flat block. The count rolls with the toggle, never behind it and never past its number. Turning it off drains the tint back into the symbol with no bounce or haptic.
  • With confirmation, a glass pill with a check buds out of the top of the capsule once the glass has taken the tint: born inside the capsule, shrunk, it springs out on a liquid neck that thins as it goes and rests joined to the capsule above it. 1.3 s after the tap it reaches its neck back out and melts home on a spring with no bounce, its words gone the moment it heads in, so nothing ever sits over the symbol. Turning the toggle off calls it home at once.
  • Style holds the tint (fill), the ink on it, the glass tint while off (restFill, clear by default), the rest ink, and the pill's glass tint (pillFill, clear by default) and ink, with house palette defaults that adapt to light and dark. The default tint is the brand red, #FF0000. tint still works and overrides fill.
  • Set isContained: false for a bare symbol that fills like a sticker under an ink outline. With no glass to flood, it keeps its halo: one ring ripples off the symbol a beat after the tap. Its pill has nothing to bud from, so it rises in on its own above the symbol.
  • The press comes from a ButtonStyle, so it tracks the real touch: it sinks about 2.5 pt per edge with no overshoot and springs back with a little give on release. It stays centered and never reads the touch point, so it is safe in scrolling feeds. The squash and the pill are visual only, so the hit area and layout never move.
  • count is the base value from your model; the view adds one while isOn so the number rolls immediately without a round trip. size scales with Dynamic Type and the hit area never drops below 44 pt. Every string and symbol is semibold.
  • Before iOS 26 the capsule and pill draw on a frosted material with a light rim, and the pill joins the capsule without a neck. Under Reduce Transparency they are solid, and the tint arrives without the flood.
  • Under Reduce Motion the flood fades in and out at full size instead of spreading and draining, the symbol and the count crossfade, the pill fades in and out where it rests, the press shifts a shade instead of sinking (darker in light mode, lighter in dark), and there is no squash or halo. Nothing waits a beat. The soft haptic still fires on the off-to-on edge only.

Usage

ReactionToggleExample()

Parameters

ParameterDescription
isOnBound reaction state.
systemImageOutline symbol name.
filledImageFilled symbol name; defaults to systemImage with .fill appended.
countOptional number shown beside the symbol; it rolls with numericText and offsets by one while isOn.
confirmationOptional pill text, such as "Saved". Turning the toggle on buds a glass pill out of the top of the capsule, joined to it by a liquid neck, which melts back in a moment later.
sizeSymbol point size; scales with Dynamic Type. The hit area is at least 44 pt.
tintOverrides the tint the glass floods with when on. Defaults to style.fill.
styleColors and shape. .standard is a neutral glass capsule that floods with the brand red under dark ink; set isContained to false for a bare symbol.

Install

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

Terminal

$npx swiftpieces add ReactionToggle

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

>Add the SwiftPieces "Reaction Toggle" 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