GlassSheet
System sheet with detents, keyboard handling and an accessible close action.
- System control
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-sheet
Drawn by the system. GlassKit configures it and leaves the glass to the system.
CaptureInstallation
spglass add glass-sheetCopies 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-sheet |
|---|---|
| Module | SPGlassComponents |
| Kind | native-wrapper — the system .sheet; the system draws the sheet and its glass |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Containers/GlassSheetExample.swift |
Minimal usage
.glassSheet(isPresented: $showsFilters, title: "Filters") {
FiltersForm()
}Variants
| Variant | Use |
|---|---|
isPresented: | Presentation driven by a Boolean. |
item: | Presentation driven by an optional Identifiable value. |
.standard | Full height, drag indicator, close button. |
.halfAndFull | Rests at half height, can be pulled to full height. |
| Custom detents | .medium, .large, .fraction(0.1...1), .height(≥ 44). |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
isPresented / item | Binding<Bool> / Binding<Item?> | — | Presentation state. |
title | LocalizedStringKey? | nil | Title of the sheet's bar. |
configuration | GlassSheetConfiguration | .standard | Options below. |
onDismiss | (@MainActor () -> Void)? | nil | Called after dismissal. |
content | @ViewBuilder | — | Content of the sheet. |
GlassSheetConfiguration:
| Field | Default | Meaning |
|---|---|---|
detents | [.large] | Resting heights; an empty list means full height. Out-of-range values are normalised. |
showsDragIndicator | true | Drag indicator visibility. |
showsCloseButton | true | System close button (ButtonRole.close) in the bar. |
isInteractiveDismissDisabled | false | Blocks swipe-to-dismiss; the close button still works. |
scrollDismissesKeyboard | true | Scrolling inside the sheet dismisses the keyboard interactively. |
States
Presented or not, owned by the host. The current detent is managed by the system.
Advanced example
.glassSheet(item: $editedContact, title: "Edit contact",
configuration: GlassSheetConfiguration(detents: [.fraction(0.45), .large], isInteractiveDismissDisabled: hasChanges)) { contact in
ContactForm(contact: contact)
.toolbar {
ToolbarItem(placement: .confirmationAction) { Button("Save") { save(contact) } }
}
}Accessibility
- The close button uses the system close role: the system provides its symbol and its localised label, and it sits in the cancellation placement where assistive technologies expect it.
- The title is a navigation title, announced as a heading.
- Keyboard avoidance, focus trapping and the Escape key are the system's.
- With
isInteractiveDismissDisabled, keepshowsCloseButtonon (or provide your own way out) so the sheet can always be left.
Limits
- When a title or the close button is requested, the content is wrapped in a
NavigationStackso that it can also add toolbar items. Passtitle: nilandshowsCloseButton: falseto present the content bare. - GlassKit adds no background: at partial height the system draws the Liquid Glass sheet. Do not add a glass surface inside.
- Detents have no effect on macOS, where sheets are sized by their content.
- The mapping to
PresentationDetentis tested; the presentation itself was compiled for iOS and macOS but not exercised in a running application by the automated tests.
Example
import SwiftUI
import SPGlassKit
public struct GlassSheetExample: GlassExample {
public static let componentID = "glass-sheet"
@State private var showsFilters = false
@State private var showsTerms = false
@State private var keyword = ""
@State private var onlyAvailable = true
public init() {}
public var body: some View {
VStack(spacing: 16) {
GlassButton("Filters", systemImage: "line.3.horizontal.decrease") { showsFilters = true }
GlassButton("Terms of use") { showsTerms = true }
}
.padding()
.glassSheet(isPresented: $showsFilters, title: "Filters", configuration: .halfAndFull) {
Form {
TextField("Keyword", text: $keyword)
Toggle("Only available", isOn: $onlyAvailable)
}
}
.glassSheet(
isPresented: $showsTerms,
title: "Terms of use",
configuration: GlassSheetConfiguration(detents: [.fraction(0.4), .large], isInteractiveDismissDisabled: true)
) {
ScrollView {
Text("Sample terms. This sheet cannot be swiped away: the close button is the way out.")
.frame(maxWidth: .infinity, alignment: .leading)
.padding()
}
}
}
}
#Preview("GlassSheet") { GlassSheetExample() }
Registry entry
| Identifier | glass-sheet |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassSheetDetent, GlassSheetConfiguration |
| Licence | MIT |
| Manifest | manifest.json |
Files
Components/Containers/GlassSheet.swift8253 bytes · sha256 ec9fee8e9497…