Skip to content
Progress Ring preview
Rendered from the SwiftUI source on this page.

Progress Ring

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

A circular progress ring with a center value.

Charts · SwiftUI · iOS 17

  • charts
  • swiftui

The actual source

ProgressRingChart.swift
// Progress Ring · syxUI · https://syxui.dev/components/chart2-progress-ring
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

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

extension View {
    func formaCard(_ pad: CGFloat = 18) -> some View {
        self.padding(pad)
            .background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 20, style: .continuous))
            .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).stroke(Color.primary.opacity(0.06), lineWidth: 1))
            .shadow(color: .black.opacity(0.05), radius: 14, x: 0, y: 6)
    }
}

// Circular progress ring
struct ProgressRingChart: View {
    let value = 0.68
    var body: some View {
        VStack(spacing: 12) {
            Text("Storage used").font(.system(size: 15, weight: .semibold)).frame(maxWidth: .infinity, alignment: .leading)
            ZStack {
                Circle().stroke(Color.primary.opacity(0.08), lineWidth: 14).frame(width: 120, height: 120)
                Circle().trim(from: 0, to: value).stroke(chBlue, style: StrokeStyle(lineWidth: 14, lineCap: .round)).frame(width: 120, height: 120).rotationEffect(.degrees(-90))
                VStack(spacing: 0) { Text("68%").font(.system(size: 26, weight: .bold)); Text("34 / 50 GB").font(.system(size: 11)).foregroundStyle(.secondary) }
            }
        }.formaCard().frame(width: 300)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17