Skip to content
Product Card preview
Rendered from the SwiftUI source on this page.

Product Card

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

A product tile - photo, rating, price and an add-to-cart button.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

ProductCard.swift
// Product Card · syxUI · https://syxui.dev/components/card-product
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Product card - photo, price, add-to-cart
struct ProductCard: View {
    let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
    var body: some View {
        VStack(alignment: .leading, spacing: 0) {
            Image("photo_product").resizable().scaledToFill().frame(width: 240, height: 150).clipped()
                .overlay(alignment: .topTrailing) {
                    Image(systemName: "heart").font(.system(size: 14)).foregroundStyle(.primary)
                        .padding(8).background(.ultraThinMaterial, in: Circle()).padding(10)
                }
            VStack(alignment: .leading, spacing: 6) {
                Text("Air Zoom Pegasus").font(.system(size: 16, weight: .semibold))
                HStack(spacing: 4) {
                    Image(systemName: "star.fill").font(.system(size: 11)).foregroundStyle(.orange)
                    Text("4.8").font(.system(size: 13, weight: .medium))
                    Text("(2.1k)").font(.system(size: 13)).foregroundStyle(.secondary)
                }
                HStack {
                    Text("$129").font(.system(size: 18, weight: .bold))
                    Spacer()
                    Image(systemName: "plus").font(.system(size: 15, weight: .semibold)).foregroundStyle(.white).frame(width: 32, height: 32).background(blue, in: Circle())
                }
            }.padding(14)
        }
        .frame(width: 240)
        .background(Color(.systemBackground)).clipShape(RoundedRectangle(cornerRadius: 20, style: .continuous))
        .overlay(RoundedRectangle(cornerRadius: 20, style: .continuous).stroke(Color.primary.opacity(0.06), lineWidth: 1))
        .shadow(color: .black.opacity(0.06), radius: 12, y: 5)
    }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • photo_product (image asset)

Requires iOS 17