GlassSplitButton
Primary action with a separate menu of secondary actions.
- System control
- iOS 26 · iPadOS 26 · macOS 26
- Version 1.1.0
glass-split-button
Drawn by the system. GlassKit configures it and leaves the glass to the system.
CaptureInstallation
spglass add glass-split-buttonCopies 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-split-button |
|---|---|
| Module | SPGlassComponents |
| Kind | native-wrapper — Menu with a primary action on macOS; a glass button and a glass menu button on iOS and iPadOS |
| Platforms | iOS 26, iPadOS 26, macOS 26 |
| Example | Examples/Gallery/Buttons/GlassSplitButtonExample.swift |
Minimal usage
GlassSplitButton("Send", systemImage: "paperplane") {
send()
} menu: {
Button("Send later…") { schedule() }
Button("Save draft") { saveDraft() }
}Variants
| Platform | Form |
|---|---|
| macOS | The system split button: Menu(content:label:primaryAction:). |
| iOS, iPadOS | Two glass buttons in one glass container: the action, and a circular menu button. Each is its own accessibility element and hit target. |
variant and size behave as for GlassButton.
Parameters
| Parameter | Type | Default | Meaning |
|---|---|---|---|
titleKey | LocalizedStringKey | — | Title of the primary action. |
systemImage | String? | nil | SF Symbol of the primary action. |
variant | GlassButtonVariant | .regular | Visual weight of both parts. |
size | GlassControlSize | .regular | Control size. |
menuAccessibilityLabel | LocalizedStringKey? | "More actions" (localised) | Name of the menu part. |
action | @MainActor () -> Void | — | Primary action. |
menu | @ViewBuilder | — | Menu content: buttons, sections, dividers. |
States
Pressed, focused and menu-open states are drawn by the system. Disable the whole control with .disabled(_:); disable single menu items on the items themselves.
Advanced example
GlassSplitButton("Export", systemImage: "square.and.arrow.up", variant: .prominent, menuAccessibilityLabel: "Export options") {
export(.pdf)
} menu: {
Section("Format") {
Button("PDF") { export(.pdf) }
Button("PNG") { export(.png) }
}
Button("Export settings…") { showSettings() }
}Accessibility
- The action and the menu are two separate, labelled elements on iOS and iPadOS.
- The menu part has its own name, "More actions" by default, in English and French.
- Both parts meet the minimum hit target.
- Menu items are standard buttons: VoiceOver, keyboard and Switch Control work as in any system menu.
Limits
- On macOS the appearance is the system's split button and does not use a separate circular menu button.
- Put the most frequent action first: the menu is for alternatives, not for the main path.
Example
import SwiftUI
import SPGlassKit
public struct GlassSplitButtonExample: GlassExample {
public static let componentID = "glass-split-button"
@State private var lastAction = "Nothing sent yet"
public init() {}
public var body: some View {
VStack(spacing: 16) {
GlassSplitButton("Send", systemImage: "paperplane", variant: .prominent) {
lastAction = "Sent now"
} menu: {
Button("Send later…", systemImage: "clock") { lastAction = "Scheduled" }
Button("Save as draft", systemImage: "tray") { lastAction = "Saved as draft" }
}
Text(lastAction).font(.callout).foregroundStyle(.secondary)
}
.padding()
}
}
#Preview("GlassSplitButton") { GlassSplitButtonExample() }
Registry entry
| Identifier | glass-split-button |
|---|---|
| Version | 1.1.0 |
| Depends on | glass-components-support, glass-foundation |
| Frameworks | SwiftUI |
| Public symbols | GlassSplitButton |
| Licence | MIT |
| Manifest | manifest.json |
Files
Components/Buttons/GlassSplitButton.swift4527 bytes · sha256 26fc915724ad…