Skip to content
Promo Banner preview
Rendered from the SwiftUI source on this page.

Promo Banner

From syxUI — written for both platforms, not translated between them.

A gradient promo banner with a CTA.

Banners · SwiftUI · iOS 17

  • banners
  • swiftui

The actual source

PromoBanner.swift
// Promo Banner · syxUI · https://syxui.dev/components/bt-promo
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let btIndigo = Color(red: 0.35, green: 0.34, blue: 0.84)
let btPurple = Color(red: 0.55, green: 0.40, blue: 0.90)

// Promo banner (gradient)
struct PromoBanner: View {
    var body: some View {
        HStack(spacing: 12) {
            Image(systemName: "gift.fill").font(.system(size: 22)).foregroundStyle(.white)
            VStack(alignment: .leading, spacing: 2) { Text("Get 20% off").font(.system(size: 15, weight: .bold)).foregroundStyle(.white); Text("Your first order with code WELCOME").font(.system(size: 12)).foregroundStyle(.white.opacity(0.9)) }
            Spacer()
            Text("Claim").font(.system(size: 13, weight: .semibold)).foregroundStyle(btPurple).padding(.horizontal, 14).padding(.vertical, 7).background(.white, in: Capsule())
        }.padding(14).frame(width: 340).background(LinearGradient(colors: [btPurple, btIndigo], startPoint: .leading, endPoint: .trailing), in: RoundedRectangle(cornerRadius: 16, style: .continuous))
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17