
Half Gauge
From syxUI — written for both platforms, not translated between them.
A half-circle gauge - credit-score style.
Charts · SwiftUI · iOS 17
- charts
- swiftui
The actual source
HalfGaugeChart.swift
// Half Gauge · syxUI · https://syxui.dev/components/chart2-half-gauge
// 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)
let chGreen = Color(red: 0.16, green: 0.66, blue: 0.40)
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)
}
}
// Half-circle gauge (speedometer)
struct HalfGaugeChart: View {
let value = 0.72
var body: some View {
VStack(spacing: 6) {
Text("Credit score").font(.system(size: 15, weight: .semibold)).frame(maxWidth: .infinity, alignment: .leading)
ZStack {
Circle().trim(from: 0.5, to: 1.0)
.stroke(Color.primary.opacity(0.08), style: StrokeStyle(lineWidth: 14, lineCap: .round))
.frame(width: 168, height: 168)
Circle().trim(from: 0.5, to: 0.5 + 0.5 * value)
.stroke(LinearGradient(colors: [chGreen, chBlue], startPoint: .leading, endPoint: .trailing), style: StrokeStyle(lineWidth: 14, lineCap: .round))
.frame(width: 168, height: 168)
VStack(spacing: 0) {
Text("724").font(.system(size: 32, weight: .bold))
Text("Good").font(.system(size: 13, weight: .medium)).foregroundStyle(chGreen)
}.offset(y: -6)
}
.frame(width: 168, height: 92, alignment: .top).clipped()
}.formaCard().frame(width: 300)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


