Docs
Controls

Liquid SwitchNew

A toggle whose red fill pours across a glass track as the thumb crosses, swelling under the finger, with a drag that follows and flips.

$npx swiftpieces add LiquidSwitch
Free · MIT + Commons ClauseiOS 17.0+Liquid Glasstoggleswitchsettingsglassdraghaptics
Type
LiquidSwitch
Files
LiquidSwitch.swift
Depends on
Nothing (Apple frameworks only)
Version
1.0.0

Colors and type for LiquidSwitch. .standard is the house palette: the brand red on neutral glass.

Notes

  • Use it like Toggle. With a title, the whole row toggles on tap, the way a settings row does. Without one, give the switch an accessibilityLabel.
  • The thumb has two edges, each on its own spring. The edge facing the move leads on a tight spring and the far edge follows on a looser one, so the thumb stretches across the track and gathers in. The red fill floods out of the thumb as it crosses, so the on state never just appears.
  • Under a finger the thumb swells toward the middle. A drag follows the finger with a soft edge at either end and flips at the midpoint, and the release carries the finger's speed into the landing. A touch the system takes over, such as a scroll, puts the thumb back.
  • Setting isOn from outside moves the thumb the same way a tap does. symbol fades an SF Symbol into the thumb as it turns on.
  • One light impact haptic fires for each flip. VoiceOver reads the switch as a toggle with its title and an On or Off value, and a double-tap flips it. .disabled(true) dims it.
  • Under Reduce Motion both edges share one short spring, so the thumb slides whole with no stretch. Reduce Transparency draws the track as a solid shape.

Usage

LiquidSwitchExample()

Install

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

Terminal

$npx swiftpieces add LiquidSwitch

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

>Add the SwiftPieces "Liquid Switch" 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 buttons and controls →

Build it yourself: SwiftUI motion guide · SwiftUI buttons 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