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

Notification Banner

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

A push-notification banner.

Banners · SwiftUI · iOS 17

  • banners
  • swiftui

The actual source

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

import SwiftUI

let btGreen = Color(red: 0.16, green: 0.66, blue: 0.40)

// Push notification banner
struct NotificationBanner: View {
    var body: some View {
        HStack(spacing: 12) {
            Image(systemName: "message.fill").font(.system(size: 20)).foregroundStyle(.white).frame(width: 40, height: 40).background(btGreen, in: RoundedRectangle(cornerRadius: 10, style: .continuous))
            VStack(alignment: .leading, spacing: 2) { HStack { Text("Messages").font(.system(size: 13, weight: .semibold)); Spacer(); Text("now").font(.system(size: 12)).foregroundStyle(.secondary) }; Text("James: Hey, are we still on for tonight?").font(.system(size: 13)).foregroundStyle(.secondary).lineLimit(2) }
        }.padding(12).frame(width: 340).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 18, style: .continuous)).overlay(RoundedRectangle(cornerRadius: 18, style: .continuous).stroke(Color.primary.opacity(0.06), lineWidth: 1)).shadow(color: .black.opacity(0.08), radius: 14, y: 5)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17