GlassPopover
| 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
swift
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
swift
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.