Fix: glassProminent Button Foreground Color Mismatch in SwiftUI

Fix: glassProminent Button Foreground Color Mismatch in SwiftUI

Written by

in

Quick answer: In iOS 26, glassProminent buttons only apply the lighter foreground tint automatically inside toolbars when using Label. Outside toolbars or with plain Text/Image, the foreground stays the tint color. The native fix arrives in iOS 27 with UIButton.Configuration.prominentGlass(). For iOS 26, apply .foregroundStyle(.white.opacity(0.9)) or a custom ButtonStyle to mimic the effect.

Why this happens

SwiftUI’s .buttonStyle(.glassProminent) behaves differently depending on context. Inside a toolbar, the system automatically lightens the label color when you use a Label view — this is a special-cased toolbar rendering path. Outside toolbars, or when the label is a plain Text or Image, SwiftUI applies the tint color directly to the foreground without the lightening adjustment.

The discrepancy exists because the toolbar’s glassProminent implementation uses a private UIKit backing that applies a semantic foreground style. The public SwiftUI button style does not expose that same semantic color resolution, so developers see the raw tint on the label.

Apple introduced a proper public API for this appearance in iOS 27 via UIKit’s UIButton.Configuration.prominentGlass(), which handles the foreground/tint relationship correctly in all contexts.

How to fix it

1. Use UIKit’s prominentGlass configuration (iOS 27+)

If your deployment target is iOS 27 or later, wrap a configured UIButton in UIViewRepresentable. This gives you the exact system appearance without custom styling.

import SwiftUI
import UIKit

struct ProminentGlassButton: UIViewRepresentable {
    var title: String
    var action: () -> Void
    var tintColor: UIColor = .systemBlue

    func makeUIView(context: Context) -> UIButton {
        var config = UIButton.Configuration.prominentGlass()
        config.buttonSize = .large
        config.cornerStyle = .capsule
        config.baseBackgroundColor = tintColor
        config.title = title

        let button = UIButton(configuration: config, primaryAction: UIAction { _ in action() })
        return button
    }

    func updateUIView(_ uiView: UIButton, context: Context) {
        var config = uiView.configuration
        config?.baseBackgroundColor = tintColor
        config?.title = title
        uiView.configuration = config
    }
}

// Usage
ProminentGlassButton(title: "Continue", tintColor: .systemPink) {
    print("Tapped")
}

The prominentGlass() configuration automatically resolves a lighter foreground for the title and image based on the background tint.

2. Apply an explicit foreground style (iOS 26 workaround)

On iOS 26, force a lighter foreground inside the button’s label. A semi-transparent white works well across most tints.

Button {
    // action
} label: {
    Label("Continue", systemImage: "arrow.right")
        .foregroundStyle(.white.opacity(0.9))
}
.buttonStyle(.glassProminent)
.tint(.pink)

If you need the label to adapt to light/dark mode, use a dynamic color:

.foregroundStyle(Color(UIColor { traits in
    traits.userInterfaceStyle == .dark ? .white : .black
}.withAlphaComponent(0.9)))

3. Create a reusable ButtonStyle that mimics the toolbar look

Encapsulate the workaround so every glassProminent button in your app gets consistent labeling.

struct ToolbarGlassProminentStyle: ButtonStyle {
    func makeBody(configuration: Configuration) -> some View {
        configuration.label
            .foregroundStyle(.white.opacity(configuration.isPressed ? 0.7 : 0.9))
            .padding(.horizontal, 16)
            .padding(.vertical, 8)
            .background(
                Capsule()
                    .fill(Color.accentColor)
                    .opacity(configuration.isPressed ? 0.8 : 1.0)
                    .shadow(color: .black.opacity(0.15), radius: 4, y: 2)
            )
            .scaleEffect(configuration.isPressed ? 0.98 : 1.0)
            .animation(.easeOut(duration: 0.1), value: configuration.isPressed)
    }
}

// Usage
Button("Save") { }
    .buttonStyle(ToolbarGlassProminentStyle())

This style replicates the capsule shape, shadow, and press animation while keeping the foreground lighter than the background tint.

How to prevent it

  • Set your deployment target to iOS 27 and adopt UIButton.Configuration.prominentGlass() for new projects.
  • If staying on iOS 26, define a single custom ButtonStyle (like ToolbarGlassProminentStyle) and apply it app-wide instead of the built-in .glassProminent.
  • Always test buttons with multiple tint colors (blue, pink, green, orange) to verify foreground contrast.
  • Avoid mixing Label, Text, and Image labels in the same button style — pick one label pattern and enforce it in your design system.

FAQ

Does .glassProminent work correctly with Label outside toolbars in iOS 26?

No. The lighter foreground only appears in toolbar items. In regular views, Label receives the same raw tint as Text or Image.

Can I use .foregroundStyle(.primary) to get the lighter color?

.primary resolves to the standard label color (black/white), not a tint-aware lighter variant. Use .white.opacity(0.9) or a custom dynamic color for the toolbar-like effect.

Is there a SwiftUI-native API coming for this?

As of iOS 27, the native solution is the UIKit prominentGlass() configuration wrapped in UIViewRepresentable. SwiftUI has not yet exposed a direct equivalent button style with the same semantic foreground behavior.

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.