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

Course Card

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

A course card with a thumbnail and a lesson progress bar.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

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

import SwiftUI

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

// Course / progress card
struct CourseCard: View {
    let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
    var body: some View {
        HStack(spacing: 12) {
            Image("photo_pet").resizable().scaledToFill().frame(width: 64, height: 64).clipShape(RoundedRectangle(cornerRadius: 12, style: .continuous))
            VStack(alignment: .leading, spacing: 6) {
                Text("Puppy Training 101").font(.system(size: 15, weight: .semibold))
                GeometryReader { g in
                    ZStack(alignment: .leading) {
                        Capsule().fill(Color.primary.opacity(0.08)).frame(height: 6)
                        Capsule().fill(blue).frame(width: g.size.width * 0.65, height: 6)
                    }
                }.frame(height: 6)
                Text("13 of 20 lessons").font(.system(size: 12)).foregroundStyle(.secondary)
            }
        }.formaCard(14).frame(width: 300)
    }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • photo_pet (image asset)

Requires iOS 17