SPB Git

Repository Public MIT

doc-glass-button-group.md 2.2 KB 62 lines markdown

1# GlassButtonGroup23| | |4|---|---|5| Identifier | `glass-button-group` |6| Module | `SPGlassComponents` |7| Kind | `custom-glass` — a `GlassEffectContainer` around related glass buttons; it adds no surface of its own |8| Platforms | iOS 26, iPadOS 26, macOS 26 |9| Example | `Examples/Gallery/Buttons/GlassButtonGroupExample.swift` |1011## Minimal usage1213```swift14GlassButtonGroup(accessibilityLabel: "Text style") {15    GlassIconButton(systemImage: "bold", accessibilityLabel: "Bold") { toggleBold() }16    GlassIconButton(systemImage: "italic", accessibilityLabel: "Italic") { toggleItalic() }17}18```1920## Variants2122| Variant | Use |23|---|---|24| `axis: .horizontal` | Toolbars and inline groups (default). |25| `axis: .vertical` | Map and canvas controls stacked on an edge. |26| `spacing` | A step of the theme's spacing scale; also the distance below which neighbouring glass shapes start to blend. |2728## Parameters2930| Parameter | Type | Default | Meaning |31|---|---|---|---|32| `axis` | `Axis` | `.horizontal` | Direction of the group. |33| `spacing` | `GlassSpacingStep` | `.xs` | Distance between buttons. |34| `accessibilityLabel` | `LocalizedStringKey?` | `nil` | Name of the group, read before its buttons. |35| `content` | `@ViewBuilder` | — | The buttons. |3637## States3839The group has no state. Selection is shown by its buttons, for example with the `.prominent` variant.4041## Advanced example4243```swift44GlassButtonGroup(axis: .vertical, spacing: .sm, accessibilityLabel: "Zoom") {45    GlassIconButton(systemImage: "plus", accessibilityLabel: "Zoom in") { zoomIn() }46    GlassIconButton(systemImage: "minus", accessibilityLabel: "Zoom out") { zoomOut() }47}48.padding()49```5051## Accessibility5253- The group is an accessibility container; give it a label so VoiceOver announces what the buttons have in common.54- Each button keeps its own label, traits and hit target.55- With Reduce Transparency the container is a plain stack and the buttons use the system's opaque treatment.5657## Limits5859- Glass cannot sample other glass: place neighbouring glass controls in one group rather than in separate containers.60- The group does not merge its buttons into a single shape; it lets the system render and blend them together.61- Do not nest a group inside another glass surface.62
Files main
Menu

Theme