Docs

SwiftUI sounds

SwiftPieces liquid glass pieces play their own sounds: short Detent clicks built into each Swift file, beside the haptics. No audio files, on by default, easy to turn off.

SwiftPieces pieces can be heard. The liquid glass pieces click, tick and open with short sounds built into the Swift file itself. There are no audio files to add, nothing to license and no package to install: copy the piece in and its sounds come with it.

The voice

Every sound is in one voice, Detent: short, dry clicks like a watch crown. Each one is rendered from code the first time it plays, so nothing is sampled. A sound always plays beside a haptic the piece already fires, so sound never adds a moment of its own. When a value steps, the click's pitch follows the value, so scrubbing rises and falls with it.

Pieces with sound

Polite by default

Sounds are on by default and stay out of the way:

  • They follow the ringer switch: silent mode means silent pieces.
  • They mix under whatever else is playing, so music keeps going.
  • They never change an audio session your app has already set up. An app that never chose an audio category gets the ambient one.

Turning sounds off

One piece: set sounds to false on its style.

LiquidSwitch("Wi-Fi", isOn: $wifi, style: LiquidSwitchStyle(sounds: false))

Every piece at once: store true for SwiftPiecesSoundsOff in UserDefaults. Binding a settings toggle to it lets people choose.

struct SoundSetting: View {
    @AppStorage("SwiftPiecesSoundsOff") private var soundsOff = false

    var body: some View {
        Toggle("Sounds", isOn: Binding(get: { !soundsOff }, set: { soundsOff = !$0 }))
    }
}

Two pieces, one app

Each piece carries its own private copy of the sound code, so pieces still stand alone and two of them in one app never collide.

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