SP GlassKit1.1.0

GlassPanel

Floating panel of actions, resizable on macOS, with managed focus.

  • Custom glass
  • iOS 26 · iPadOS 26 · macOS 26
  • Version 1.1.0
  • glass-panel

Draws its own Liquid Glass surface, with an opaque form when Reduce Transparency is on.

GlassPanel 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-panel

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-panel
ModuleSPGlassComponents
Kindcustom-glass — one glassSurface; the controls inside are plain system controls
PlatformsiOS 26, iPadOS 26, macOS 26 (resizing and focus scope on macOS only)
ExampleExamples/Gallery/Containers/GlassPanelExample.swift

Minimal usage

Swift
GlassPanel("Layers") {
    Toggle("Transit", isOn: $showsTransit)
}

Variants

VariantUse
FixedNo size: the panel takes the size of its content.
Resizable (macOS)size: $panelSize: a handle in the trailing-bottom corner resizes within sizeLimits.
ClosableonClose: adds a close button; Escape calls it.

Parameters

ParameterTypeDefaultMeaning
titleLocalizedStringKey or Text—Heading and accessibility label of the panel.
sizeBinding<CGSize>?nilControlled size on macOS. Ignored on iOS and iPadOS.
sizeLimitsGlassPanelSizeLimits.standard (240 × 160 to 720 × 640)Bounds applied to size.
onClose(@MainActor () -> Void)?nilShows the close button and handles Escape.
content@ViewBuilder—Controls of the panel.

GlassPanelSizeLimits.clamp(_:) and resized(from:translation:isRightToLeft:) are pure and can be reused by the host, for example to restore a saved size.

Appearance

The title bar is separated from the content by a hairline and the close button is a small circular control. The panel uses neutral glass (never the theme's glass tint) so that its text and controls stay legible in every theme.

States

The panel itself has no state. The host decides whether it is shown; size is the host's state. While the handle is dragged the size follows the pointer immediately, without animation.

Advanced example

Swift
@State private var size = CGSize(width: 320, height: 240)
let limits = GlassPanelSizeLimits(minimum: CGSize(width: 260, height: 180), maximum: CGSize(width: 520, height: 420))

GlassPanel("Inspector", size: $size, sizeLimits: limits, onClose: { showsInspector = false }) {
    Picker("Blend", selection: $blend) { ForEach(Blend.allCases) { Text($0.name).tag($0) } }
    Slider(value: $opacity, in: 0...1) { Text("Opacity") }
}
.onChange(of: size) { _, new in settings.inspectorSize = limits.clamp(new) }

Accessibility

  • The panel is an accessibility container named by its title; the title has the header trait.
  • The close button is labelled "Close" (localised) and has the minimum hit target.
  • macOS: the panel is a focus scope and a focus section, so Tab and arrow keys move among its controls as a group. Escape calls onClose while focus is inside the panel.
  • iOS and iPadOS with a hardware keyboard: Escape triggers the close button (.keyboardShortcut(.cancelAction)).
  • The resize handle is focusable (arrow keys resize by one spacing step), is announced as "Resize panel" with the current size as its value, and supports the VoiceOver adjustable action.
  • With Reduce Transparency the surface is opaque (handled by glassSurface).

Limits

  • The panel does not move itself: place it with overlay, safeAreaInset or your own drag logic.
  • Resizing exists on macOS only; on iPadOS use a sheet with detents or GlassMapPanel for an extensible panel.
  • Keep the content to controls and short labels; long or dense content belongs in an opaque GlassCard.
  • Do not put glass buttons (GlassButton) inside the panel: glass must not sit inside glass. Use plain or bordered system buttons.
  • The behaviour of focus and Escape was compiled but not exercised in a running application by the automated tests.

Example

Complete example (compiled with the package)
import SwiftUI
import SPGlassKit

public struct GlassPanelExample: GlassExample {
    public static let componentID = "glass-panel"
    @State private var isShown = true
    @State private var showsTransit = true
    @State private var showsTraffic = false
    @State private var size = CGSize(width: 300, height: 220)

    public init() {}

    public var body: some View {
        ZStack {
            LinearGradient(colors: [.teal, .indigo], startPoint: .topLeading, endPoint: .bottomTrailing)
                .ignoresSafeArea()
                .accessibilityHidden(true)
            if isShown {
                GlassPanel(
                    "Layers",
                    size: $size,
                    sizeLimits: GlassPanelSizeLimits(minimum: CGSize(width: 240, height: 180), maximum: CGSize(width: 480, height: 360)),
                    onClose: { isShown = false }
                ) {
                    Toggle("Transit", isOn: $showsTransit)
                    Toggle("Traffic", isOn: $showsTraffic)
                }
                .padding()
            } else {
                GlassButton("Show layers", systemImage: "square.3.layers.3d") { isShown = true }
            }
        }
    }
}

#Preview("GlassPanel") { GlassPanelExample() }

Registry entry

Identifierglass-panel
Version1.1.0
Depends onglass-foundation
FrameworksSwiftUI
Public symbolsGlassPanelSizeLimits, GlassPanel
LicenceMIT
Manifestmanifest.json

Files