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

Rating Prompt

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

An app-rating prompt with stars.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

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

import SwiftUI

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)
}

// Rating prompt
struct RatingPrompt: View {
    var body: some View {
        shCard(300, radius: 22) {
            VStack(spacing: 12) {
                Text("Enjoying the app?").font(.system(size: 18, weight: .bold))
                Text("Tap a star to rate it on the App Store.").font(.system(size: 14)).foregroundStyle(.secondary)
                HStack(spacing: 8) { ForEach(0..<5, id: \.self) { i in Image(systemName: i < 4 ? "star.fill" : "star").font(.system(size: 26)).foregroundStyle(.orange) } }
                Text("Maybe Later").font(.system(size: 15)).foregroundStyle(.secondary)
            }.padding(20)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17