Autumn Sale50% offCOMPOT
Banners & PromosPro ComponentiOS 16.0+Xcode 15+

Banner with Action – TipKit Style

Native TipKit-style contextual recommendation banner with action and dismiss triggers.

SwiftUI Implementation

Pure Vanilla Swift • No Dependencies
bannerWActionTipKitStyle.swift
import SwiftUI

struct UseBannerWActionTipKitStyle: View {
    
    @State private var showBanner: Bool = true
    
    private func bannerAction() {
        print("Tap on the button")
    }
    
    var body: some View {
        VStack {
            if showBanner {
                BannerWActionTipKitStyle(isShowing: $showBanner, symbol: "photo.badge.plus", title: "Add New Tour", message: "You can add a new tour to your itinerary in two easy steps. Try it out, you will love it!", buttonLabel: "Get Started", action: bannerAction)
            } else {
                Button("Show Banner") {
                    showBanner = true
                }
            }
        }
        .padding()
    }
}

#Preview {
    UseBannerWActionTipKitStyle()
}

struct BannerWActionTipKitStyle: View {
    
    @Binding var isShowing: Bool
    let symbol: String
    let title: String
    let message: String
    let buttonLabel: String
    let action: () -> Void
    
    var body: some View {
        
        HStack(alignment: .top, spacing: 12) {
            Image(systemName: symbol)
                .font(.system(size: 36, weight: .regular))
                .symbolRenderingMode(.multicolor)
            VStack(alignment: .leading) {
                VStack(alignment: .leading, spacing: 4) {
                    Text(title)
                        .font(.system(size: 16, weight: .bold))
                        .foregroundStyle(.primary)
                        .multilineTextAlignment(.leading)
                    Text(message)
                        .font(.system(size: 15, weight: .regular))
                        .foregroundStyle(.secondary)
                        .multilineTextAlignment(.leading)
                }
                .padding(.trailing)
                
                Divider()
                    .padding(.bottom, 6)
                
                Button {
                    action()
                } label: {
                    Text(buttonLabel)
                        .font(.system(size: 15, weight: .bold))
                }
            }
            .padding(.bottom)
            .frame(maxWidth: 390, alignment: .topLeading)
        }
        .padding(.top)
        .padding(.leading, 12)
        .frame(maxWidth: .infinity, alignment: .topLeading)
        .background(.thinMaterial, in: RoundedRectangle(cornerRadius: 12.0, style: .continuous))
        .overlay(alignment: .topTrailing) {
            Button {
                isShowing = false
            } label: {
                Image(systemName: "xmark")
                    .font(.system(size: 16, weight: .bold))
                    .foregroundStyle(.tertiary)
            }
            .padding(.top)
            .padding(.horizontal, 12)
            .buttonStyle(.plain)
        }
    }
}

Ready to copy and paste directly into any Xcode project running iOS 16.0+.

Recommended Use Cases

  • App settings, preferences, and account configuration screens
  • Dashboard overviews, stats tracking, and metric highlights

Component Details

iOS Compatibility
iOS 16.0+
Xcode Version
Xcode 15+
Platform
iOS
License Tier
Pro
Themes & Contexts
settingsdashboard
Keywords
bannernotificationactiontipswiftui
C

Compot for iOS

Native SwiftUI playground app

Preview all 130+ components interactively on your device and copy code straight to Xcode with 1 tap.

Get Compot on the App Store