Skip to content
Social Post preview
Rendered from the SwiftUI source on this page.

Social Post

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

A social post - author, text, photo and like / comment actions.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

SocialPostCard.swift
// Social Post · syxUI · https://syxui.dev/components/card-social
// 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)
    }
}

// Social post card
struct SocialPostCard: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 10) {
            HStack(spacing: 10) {
                Image("person_1").resizable().scaledToFill().frame(width: 40, height: 40).clipShape(Circle())
                VStack(alignment: .leading, spacing: 1) {
                    Text("Amara Kelly").font(.system(size: 15, weight: .semibold))
                    Text("2 hours ago").font(.system(size: 12)).foregroundStyle(.secondary)
                }
                Spacer()
                Image(systemName: "ellipsis").foregroundStyle(.secondary)
            }
            Text("Meet the newest member of the family! ").font(.system(size: 14))
            Image("photo_pet").resizable().scaledToFill().frame(height: 180).frame(maxWidth: .infinity).clipShape(RoundedRectangle(cornerRadius: 14, style: .continuous))
            HStack(spacing: 22) {
                Label("248", systemImage: "heart").font(.system(size: 14)).foregroundStyle(.secondary)
                Label("32", systemImage: "bubble.right").font(.system(size: 14)).foregroundStyle(.secondary)
                Spacer()
                Image(systemName: "bookmark").font(.system(size: 15)).foregroundStyle(.secondary)
            }
        }.formaCard(14).frame(width: 320)
    }
}
iOS 17 · 2 dependencies

Dependencies

SwiftUI
  • person_1 (image asset)
  • photo_pet (image asset)

Requires iOS 17