SP GlassKit1.1.0

GlassBanner

Inline information, success, warning or error message with icon, text and dismissal.

  • Content
  • iOS 26 · iPadOS 26 · macOS 26
  • Version 1.1.0
  • glass-banner

Content on an opaque, readable surface. Glass is kept for controls.

GlassBanner running in SP Glass Studio.Capture
Capture of the component running in SP Glass Studio on the iOS 26.5 simulator. Liquid Glass is rendered by the system; this is an image, not a live preview.

Installation

spglass add glass-banner

Copies the sources and their dependencies into your project. Set up the CLI.

Swift
.package(url: "https://git.spboucher.ai/sp-glasskit.git", from: "1.1.0")

import SPGlassKit
Identifierglass-banner
ModuleSPGlassComponents
Kindcontent-component — opaque surface tinted with the severity colour; no glass
PlatformsiOS 26, iPadOS 26, macOS 26
ExampleExamples/Gallery/Feedback/GlassBannerExample.swift

Minimal usage

Swift
GlassBanner(.success, title: "Payment received")

Variants

SeveritySymbolWordTheme role
.informationinfo.circle.fillInformationaccent
.successcheckmark.circle.fillSuccesssuccess
.warningexclamationmark.triangle.fillWarningwarning
.errorxmark.octagon.fillErrordestructive

Each severity is shown three ways: a symbol of a distinct shape, its name in text, and the tint. Options: message, action, onDismiss.

Parameters

ParameterTypeDefaultMeaning
severityGlassBannerSeverity—See Variants.
titleLocalizedStringKey, verbatim: string or Text—Main line.
messageString? (or Text?)nilDetail, shown as is.
actionGlassBannerAction?nilOne button (GlassBannerAction("Retry") { … } or verbatim:).
onDismiss(@MainActor () -> Void)?nilShows a dismiss button.

Appearance

The banner is an opaque surface barely tinted with the severity colour, with a hairline, an accent edge on the leading side and the severity symbol in a tinted tile. The severity word is an uppercase eyebrow label above the title; the optional action is a small capsule button.

States

The banner is stateless: the host shows or removes it. It stays in the layout (it is not transient like a toast).

Colours come from GlassTintedColors.resolve(tint:surface:text:): the background is the theme surface mixed with 14 % of the severity colour; the text is the theme's primary text colour when it reaches 4.5:1 against that background, otherwise black or white; the symbol and outline use the severity colour when it reaches 3:1, otherwise the text colour. Tests check these ratios for every built-in theme in light and dark.

Advanced example

Swift
if let failure = model.syncFailure {
    GlassBanner(.error, verbatim: failure.localizedDescription,
                message: failure.recoverySuggestion,
                action: GlassBannerAction("Retry") { model.sync() },
                onDismiss: { model.syncFailure = nil })
        .transition(.opacity)
}

Accessibility

  • VoiceOver reads the severity word, the title and the message as one element; the symbol is hidden because the word says the same thing.
  • The action and dismiss buttons are separate elements with labels and the minimum hit target; the action is underlined so that it is recognisable without colour.
  • Text wraps and follows Dynamic Type; the symbol aligns to the top so long messages stay readable.
  • For an error that appears while the user is elsewhere on screen, also post an announcement or move focus: the banner does not announce itself.

Limits

  • With the System theme (roles left to the system) colours cannot be measured: the background is mixed by SwiftUI and text and symbol use the primary label colour.
  • One action at most. For several choices use a GlassAlert.
  • The severity word is GlassKit's (English and French); the title and message are the host's.

Example

Complete example (compiled with the package)
import SwiftUI
import SPGlassKit

public struct GlassBannerExample: GlassExample {
    public static let componentID = "glass-banner"
    @State private var showsWarning = true
    @State private var retryCount = 0

    public init() {}

    public var body: some View {
        ScrollView {
            VStack(spacing: 12) {
                GlassBanner(.information, title: "Maintenance on Sunday", message: "The sample service will be read-only from 2:00 to 4:00.")
                GlassBanner(.success, title: "Payment received")
                if showsWarning {
                    GlassBanner(
                        .warning,
                        title: "Your card expires soon",
                        message: "Update your payment method before the end of the month to avoid an interruption.",
                        action: GlassBannerAction("Update card") { showsWarning = false },
                        onDismiss: { showsWarning = false }
                    )
                }
                GlassBanner(
                    .error,
                    verbatim: "Synchronisation failed (attempt \(retryCount + 1))",
                    message: "The server did not answer.",
                    action: GlassBannerAction("Retry") { retryCount += 1 }
                )
            }
            .padding()
        }
    }
}

#Preview("GlassBanner") { GlassBannerExample().glassTheme(.emerald) }

Registry entry

Identifierglass-banner
Version1.1.0
Depends onglass-components-support, glass-foundation
FrameworksSwiftUI
Public symbolsGlassBannerSeverity, GlassBannerAction, GlassBanner
LicenceMIT
Manifestmanifest.json

Files