Skip to content
Rating Badges preview
Rendered from the SwiftUI source on this page.

Rating Badges

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

Star rating badges.

Badges · SwiftUI · iOS 17

  • badges
  • swiftui

The actual source

RatingBadges.swift
// Rating Badges · syxUI · https://syxui.dev/components/tag-rating
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

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

// Rating badges
struct RatingBadges: View {
    var body: some View {
        HStack(spacing: 10) {
            HStack(spacing: 4) { Image(systemName: "star.fill").font(.system(size: 12)).foregroundStyle(.orange); Text("4.8").font(.system(size: 14, weight: .bold)) }.padding(.horizontal, 10).padding(.vertical, 6).background(Color.primary.opacity(0.05), in: Capsule())
            HStack(spacing: 4) { Image(systemName: "star.fill").font(.system(size: 11)).foregroundStyle(.white); Text("4.9").font(.system(size: 13, weight: .bold)).foregroundStyle(.white) }.padding(.horizontal, 10).padding(.vertical, 6).background(tgGreen, in: Capsule())
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17