GlassToggle
| Identifier | glass-toggle |
| Module | SPGlassForms |
| Kind | native-wrapper — the system Toggle, tinted with the theme's primary colour |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Selection/GlassToggleExample.swift |
Minimal usage
swift
@State private var notifications = true
GlassToggle("Notifications", isOn: $notifications)Variants
| Variant | Use |
|---|---|
description: |
A secondary line under the title. |
systemImage: |
A decorative symbol before the title. |
appearance: .switch |
Always a switch. |
appearance: .checkbox |
A checkbox on macOS; a switch on iOS and iPadOS, which have no checkbox. |
appearance: .automatic (default) |
The platform's default. |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
title |
LocalizedStringKey or Text |
— | Title. |
description |
LocalizedStringKey? or Text? |
nil |
Description. |
systemImage |
String? |
nil |
SF Symbol. |
appearance |
GlassToggleAppearance |
.automatic |
Switch or checkbox. |
isOn |
Binding<Bool> |
— | The value. |
States
On, off, pressed and focused are drawn by the system. Disabled is the standard .disabled(_:) modifier.
Advanced example
swift
Form {
Section("Privacy") {
GlassToggle("Share diagnostics", description: "Crash reports without personal data.",
systemImage: "stethoscope", isOn: $settings.diagnostics)
GlassToggle(title: Text(verbatim: account.name), description: Text("Sync this account"), isOn: $account.isSynced)
.disabled(!settings.isOnline)
}
}Accessibility
- Title and description form the label of the toggle, so VoiceOver reads both, then the state.
- The symbol is hidden from assistive technologies.
- Title and description wrap at large text sizes; nothing is truncated.
- The state is the position of the switch (and, with the system setting, its on/off labels), not the tint alone.
Limits
- The switch itself, including its glass thumb, is drawn by the system and cannot be restyled.
- The checkbox appearance exists only on macOS.
- No built-in loading state; disable the toggle while a change is being saved.