GlassToggle
System toggle with title, description and disabled state.
- System control
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-toggle
Drawn by the system. GlassKit configures it and leaves the glass to the system.
CaptureInstallation
spglass add glass-toggleCopies the sources and their dependencies into your project. Set up the CLI.
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")
import SPGlassKit| 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
@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
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 symbol sits on a small tinted tile; tile and symbol take the
primarycolour while the toggle is on, the secondary text colour while it is off (the switch still carries the state). - The checkbox appearance exists only on macOS.
- No built-in loading state; disable the toggle while a change is being saved.
Example
import SwiftUI
import SPGlassKit
public struct GlassToggleExample: GlassExample {
public static let componentID = "glass-toggle"
@State private var notifications = true
@State private var summary = false
@State private var analytics = false
@State private var terms = false
public init() {}
public var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 20) {
GlassToggle("Notifications", isOn: $notifications)
GlassToggle(
"Weekly summary",
description: "A digest every Monday morning with the activity of the previous week, sent to the address of your account.",
systemImage: "envelope",
isOn: $summary
)
GlassToggle("Share usage statistics", description: "Managed by your organisation.", isOn: $analytics)
.disabled(true)
GlassToggle("I accept the terms", appearance: .checkbox, isOn: $terms)
}
.padding()
}
}
}
#Preview("GlassToggle") { GlassToggleExample().glassTheme(.emerald) }
Registry entry
| Identifier | glass-toggle |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassToggleAppearance, GlassToggle |
| Licence | MIT |
| Manifest | manifest.json |
Files
Forms/Selection/GlassToggle.swift5576 bytes · sha256 6f1c93f7a8c6…