GlassButtonGroup
Related glass buttons rendered in one glass container so that they blend consistently.
- Custom glass
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-button-group
Draws its own Liquid Glass surface, with an opaque form when Reduce Transparency is on.
CaptureInstallation
spglass add glass-button-groupCopies 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-button-group |
|---|---|
| Module | SPGlassComponents |
| Kind | custom-glass — a GlassEffectContainer around related glass buttons; it adds no surface of its own |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Buttons/GlassButtonGroupExample.swift |
Minimal usage
GlassButtonGroup(accessibilityLabel: "Text style") {
GlassIconButton(systemImage: "bold", accessibilityLabel: "Bold") { toggleBold() }
GlassIconButton(systemImage: "italic", accessibilityLabel: "Italic") { toggleItalic() }
}Variants
| Variant | Use |
|---|---|
axis: .horizontal | Toolbars and inline groups (default). |
axis: .vertical | Map and canvas controls stacked on an edge. |
spacing | A step of the theme's spacing scale; also the distance below which neighbouring glass shapes start to blend. |
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
axis | Axis | .horizontal | Direction of the group. |
spacing | GlassSpacingStep | .xs | Distance between buttons. |
accessibilityLabel | LocalizedStringKey? | nil | Name of the group, read before its buttons. |
content | @ViewBuilder | — | The buttons. |
States
The group has no state. Selection is shown by its buttons, for example with the .prominent variant.
Advanced example
GlassButtonGroup(axis: .vertical, spacing: .sm, accessibilityLabel: "Zoom") {
GlassIconButton(systemImage: "plus", accessibilityLabel: "Zoom in") { zoomIn() }
GlassIconButton(systemImage: "minus", accessibilityLabel: "Zoom out") { zoomOut() }
}
.padding()Accessibility
- The group is an accessibility container; give it a label so VoiceOver announces what the buttons have in common.
- Each button keeps its own label, traits and hit target.
- With Reduce Transparency the container is a plain stack and the buttons use the system's opaque treatment.
Limits
- Glass cannot sample other glass: place neighbouring glass controls in one group rather than in separate containers.
- The group does not merge its buttons into a single shape; it lets the system render and blend them together.
- Do not nest a group inside another glass surface.
Example
import SwiftUI
import SPGlassKit
public struct GlassButtonGroupExample: GlassExample {
public static let componentID = "glass-button-group"
@State private var styles: Set<String> = []
public init() {}
public var body: some View {
VStack(spacing: 24) {
GlassButtonGroup(accessibilityLabel: "Text style") {
ForEach(["bold", "italic", "underline"], id: \.self) { style in
GlassIconButton(
systemImage: style,
label: Text(style.capitalized),
variant: styles.contains(style) ? .prominent : .regular
) {
styles.formSymmetricDifference([style])
}
}
}
GlassButtonGroup(axis: .vertical, spacing: .sm, accessibilityLabel: "Zoom") {
GlassIconButton(systemImage: "plus", accessibilityLabel: "Zoom in") {}
GlassIconButton(systemImage: "minus", accessibilityLabel: "Zoom out") {}
}
}
.padding()
}
}
#Preview("GlassButtonGroup") { GlassButtonGroupExample() }
Registry entry
| Identifier | glass-button-group |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassButtonGroup |
| Licence | MIT |
| Manifest | manifest.json |
Files
Components/Buttons/GlassButtonGroup.swift3481 bytes · sha256 cba371feea97…