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

Profile Card

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

A user profile - avatar, handle, follower stats and a follow button.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

ProfileCard.swift
// Profile Card · syxUI · https://syxui.dev/components/card-profile
// 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)
    }
}

// Profile card - avatar, stats, follow
struct ProfileCard: View {
    let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
    var body: some View {
        VStack(spacing: 12) {
            Image("person_1").resizable().scaledToFill().frame(width: 76, height: 76).clipShape(Circle())
            VStack(spacing: 3) {
                Text("Amara Kelly").font(.system(size: 18, weight: .semibold))
                Text("@amara.designs").font(.system(size: 13)).foregroundStyle(.secondary)
            }
            HStack(spacing: 0) {
                stat("248", "Posts"); divider(); stat("12.4k", "Followers"); divider(); stat("380", "Following")
            }
            Text("Follow").font(.system(size: 15, weight: .semibold)).foregroundStyle(.white)
                .frame(maxWidth: .infinity).padding(.vertical, 10).background(blue, in: Capsule())
        }.formaCard()
    }
    func stat(_ v: String, _ l: String) -> some View {
        VStack(spacing: 2) {
            Text(v).font(.system(size: 16, weight: .bold))
            Text(l).font(.system(size: 12)).foregroundStyle(.secondary)
        }.frame(maxWidth: .infinity)
    }
    func divider() -> some View { Rectangle().fill(Color.primary.opacity(0.08)).frame(width: 1, height: 28) }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • person_1 (image asset)

Requires iOS 17