Skip to content
Solid Warning preview
Rendered from the SwiftUI source on this page.

Solid Warning

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

A filled warning banner.

Banners · SwiftUI · iOS 17

  • banners
  • swiftui

The actual source

BannerWarningSolid.swift
// Solid Warning · syxUI · https://syxui.dev/components/bt-warning-solid
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let btOrange = Color(red: 0.98, green: 0.55, blue: 0.10)

func solidBanner(_ icon: String, _ color: Color, _ title: String, _ subtitle: String) -> some View {
    HStack(spacing: 12) {
        Image(systemName: icon).font(.system(size: 20)).foregroundStyle(.white)
        VStack(alignment: .leading, spacing: 2) { Text(title).font(.system(size: 14, weight: .semibold)).foregroundStyle(.white); Text(subtitle).font(.system(size: 13)).foregroundStyle(.white.opacity(0.85)) }
        Spacer(minLength: 8)
        Image(systemName: "xmark").font(.system(size: 12, weight: .bold)).foregroundStyle(.white.opacity(0.8))
    }.padding(14).frame(width: 330).background(color, in: RoundedRectangle(cornerRadius: 14, style: .continuous)).shadow(color: color.opacity(0.3), radius: 10, y: 4)
}

struct BannerWarningSolid: View { var body: some View { solidBanner("exclamationmark.triangle.fill", btOrange, "Action required", "Confirm your details to continue.") } }
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17