Skip to content
Loading Modal preview
Rendered from the SwiftUI source on this page.

Loading Modal

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

A blocking loading modal with a spinner.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

LoadingModal.swift
// Loading Modal · syxUI · https://syxui.dev/components/sheet-loading
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let shBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

func shCard<C: View>(_ w: CGFloat, radius: CGFloat = 18, @ViewBuilder _ c: () -> C) -> some View {
    c().frame(width: w).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: radius, style: .continuous)).overlay(RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(Color.primary.opacity(0.07), lineWidth: 1)).shadow(color: .black.opacity(0.05), radius: 12, y: 5)
}

// Loading modal
struct LoadingModal: View {
    var body: some View {
        shCard(200, radius: 20) {
            VStack(spacing: 14) {
                Circle().trim(from: 0, to: 0.7).stroke(shBlue, style: StrokeStyle(lineWidth: 4, lineCap: .round)).frame(width: 40, height: 40)
                Text("Processing…").font(.system(size: 15, weight: .medium))
            }.padding(28)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17