Docs
Glass

Glass Mode Bar

One liquid glass bar that turns into the mode you pick, its icons trading places with that mode's own controls.

By · Updated

Glass Mode Bar: SwiftUI component for iOS, live preview in light mode

Glass Mode Bar, a SwiftUI component for iOS 17+, in its live preview. Open Code for the Swift source.

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

One liquid glass body that becomes the controls of the mode you pick, without leaving its place. At rest a capsule spans the width offered, its mode icons spread evenly across it. Tapping a mode buds a signal anchor out of the capsule's leading end, carrying that mode's icon, while the capsule draws its leading edge back to make room and trades its icons for the mode's controls, which you build. The two rest joined, one body. Tapping the anchor melts it home into the capsule as the icons return. The outer edges never move. swift @State private var mode: String? GlassModeBar(modes: [ .init(id: "voice", systemImage: "mic", title: "Voice"), .init(id: "timer", systemImage: "timer", title: "Timer"), ], selection: $mode) { mode in switch mode.id { case "voice": RecordingControls() default: TimerChips() } }

Notes

  • It has sound built in: a ratchet as a mode opens and as it closes. They are short Detent clicks rendered from code inside this file, so there are no audio files to add. They play beside the haptics, go quiet with the ringer switch and mix under music. Turn them off with the style's sounds: false, or for every piece at once with @AppStorage("SwiftPiecesSoundsOff").
  • One body that keeps its footprint. At rest a liquid glass capsule spans the width offered, its mode icons spread evenly across it. Open a mode and the capsule draws its leading edge back while a signal anchor carrying that mode's icon buds out of its leading end, born inside it, shrunk, and pulled out through a neck to rest joined beside it. Neither outer edge moves.
  • The capsule trades its icons for the open mode's controls, which you build in panel: they blur in where the icons blurred out, on the reveal and dismiss roles. The panel gets the capsule's height (56pt) and the full width beside the anchor, so give its contents maxWidth: .infinity to span it, as the example's waveform, photos, chips and format buttons do; keep it plain content, since the capsule is already the glass. The example turns Voice into a live waveform and a running time, Photo into recent shots, Timer into duration chips and Text into format controls.
  • Every change overlaps, so the body is never blank: opening, the panel blurs in as the icons blur out while the anchor buds; closing, the anchor melts home on the bounceless home spring and the icons start coming back 160ms in, while the capsule reaches back for it. The anchor keeps its glyph until it is inside. Setting selection from your code opens, closes or switches a mode the same way; switching swaps the panel and the anchor's glyph in place.
  • Haptics: a selection tick as a mode opens, a soft impact as it closes.
  • On iOS 26 the capsule and the anchor are Liquid Glass and the neck forms between them; before that they are frosted glass that simply sit side by side, and under Reduce Transparency they are solid.
  • Reduce Motion: the anchor fades in and out where it rests instead of budding, the capsule's edge moves on a short spring with no overshoot, and the icon and panel swaps cross-fade.
  • VoiceOver: each mode icon is a button with its title; the anchor reads "Close" and the mode's title. Panels are your views, so give their controls labels.
  • Style (GlassModeBarStyle) sets the icons' colour, the anchor's ink and the anchor's tint (signal by default). Mode is GlassModeBarMode: an id, an SF Symbol and a title. All text and symbols are semibold.

Usage

GlassModeBarExample()

Parameters

ParameterDescription
modesThe modes, in order across the capsule.
selectionThe open mode's id, or nil at rest. Set it yourself to open or close a mode from your code.
styleColors. Defaults to the SwiftPieces house palette, adapting to light and dark.
panelThe controls for a mode, laid out in the capsule beside the anchor. They fill the capsule's height (56pt)

Install

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

Terminal

$npx swiftpieces add GlassModeBar

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

>Add the SwiftPieces "Glass Mode Bar" 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 liquid glass →

Build it yourself: Liquid Glass 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.

Explore Pro