GlassPopover
System popover with anchoring, compact adaptation and an accessible close action.
- System control
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-popover
Drawn by the system. GlassKit configures it and leaves the glass to the system.
CaptureInstallation
spglass add glass-popoverCopies 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-popover |
|---|---|
| Module | SPGlassComponents |
| Kind | native-wrapper — the system .popover; the system draws the popover and its glass |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Containers/GlassPopoverExample.swift |
Minimal usage
GlassIconButton(systemImage: "info", accessibilityLabel: "Details") { showsInfo = true }
.glassPopover(isPresented: $showsInfo) {
Text("Prices include taxes.").padding()
}Variants
compactAdaptation | In a compact size class (iPhone, narrow iPad window) |
|---|---|
.automatic (default) | The system's choice: a sheet. |
.popover | Stays a popover with its arrow. For short content. |
.sheet | A sheet. |
.fullScreenCover | A full-screen cover. |
In a regular size class and on macOS the popover is always a popover.
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
isPresented | Binding<Bool> | — | Presentation state. |
title | LocalizedStringKey? | nil | Heading shown above the content. |
attachmentAnchor | PopoverAttachmentAnchor | .rect(.bounds) | Where the popover is attached on the source view. |
arrowEdge | Edge? | nil | Preferred edge carrying the arrow; nil lets the system choose. |
compactAdaptation | GlassPopoverAdaptation | .automatic | See Variants. |
content | @ViewBuilder | — | Content; it supplies its own padding. |
States
Presented or not, owned by the host. When the popover is adapted to a sheet or a cover, a close button appears in a title row above the content (GlassPopoverAdaptation.needsCloseButton(isCompact:platform:)).
Advanced example
GlassButton("Sort", systemImage: "arrow.up.arrow.down") { showsSort = true }
.glassPopover(isPresented: $showsSort, title: "Sort by", attachmentAnchor: .point(.bottom), arrowEdge: .top, compactAdaptation: .popover) {
Picker("Sort by", selection: $order) {
ForEach(SortOrder.allCases) { Text($0.title).tag($0) }
}
.pickerStyle(.inline)
.labelsHidden()
.padding()
}Accessibility
- A real popover is dismissed by tapping outside, by Escape and by the VoiceOver escape gesture; all are the system's.
- An adapted popover has no outside area: the added close button uses the system close role (symbol and localised label supplied by the system) and answers Escape on a hardware keyboard.
- The title carries the header trait.
Limits
- The close-button rule reads the size classes of the presented content. In a compact height with a regular width (some iPhones in landscape) the system may keep a popover while the rule shows the button; the button is then redundant but harmless.
- The system may place the arrow on another edge than
arrowEdgewhen there is no room. - GlassKit adds no surface; do not add glass inside the popover.
- The adaptation was compiled for iOS and macOS; the rule deciding the close button is unit-tested, the presentation was not exercised in a running application by the automated tests.
Example
import SwiftUI
import SPGlassKit
public struct GlassPopoverExample: GlassExample {
public static let componentID = "glass-popover"
@State private var showsDetails = false
@State private var showsHelp = false
public init() {}
public var body: some View {
HStack(spacing: 24) {
GlassIconButton(systemImage: "info", accessibilityLabel: "Price details") { showsDetails = true }
.glassPopover(isPresented: $showsDetails, title: "Price details", arrowEdge: .top, compactAdaptation: .popover) {
Text("Sample price, taxes included.")
.padding()
.frame(minWidth: 220, alignment: .leading)
}
GlassButton("Help", systemImage: "questionmark.circle") { showsHelp = true }
.glassPopover(isPresented: $showsHelp, title: "Help", compactAdaptation: .sheet) {
Text("On a compact width this popover becomes a sheet with a close button.")
.padding()
.frame(maxWidth: .infinity, alignment: .leading)
}
}
.padding()
}
}
#Preview("GlassPopover") { GlassPopoverExample() }
Registry entry
| Identifier | glass-popover |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassPopoverAdaptation |
| Licence | MIT |
| Manifest | manifest.json |
Files
Components/Containers/GlassPopover.swift6002 bytes · sha256 8874783cc28a…