SP GlassKit1.1.0

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.

GlassToggle running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-toggle

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-toggle
ModuleSPGlassForms
Kindnative-wrapper — the system Toggle, tinted with the theme's primary colour
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Selection/GlassToggleExample.swift

Minimal usage

Swift
@State private var notifications = true

GlassToggle("Notifications", isOn: $notifications)

Variants

VariantUse
description:A secondary line under the title.
systemImage:A decorative symbol before the title.
appearance: .switchAlways a switch.
appearance: .checkboxA checkbox on macOS; a switch on iOS and iPadOS, which have no checkbox.
appearance: .automatic (default)The platform's default.

Parameters

ParameterTypeDefaultMeaning
titleLocalizedStringKey or Text—Title.
descriptionLocalizedStringKey? or Text?nilDescription.
systemImageString?nilSF Symbol.
appearanceGlassToggleAppearance.automaticSwitch or checkbox.
isOnBinding<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 symbol sits on a small tinted tile; tile and symbol take the primary colour 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

Complete example (compiled with the package)
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

Identifierglass-toggle
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassToggleAppearance, GlassToggle
LicenceMIT
Manifestmanifest.json

Files