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

Transactions

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

A transaction ledger with icons and signed amounts.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

TableTransactions.swift
// Transactions · syxUI · https://syxui.dev/components/table-transactions
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let tblGreen = Color(red: 0.13, green: 0.62, blue: 0.32)

extension View {
    func tblCard(_ w: CGFloat) -> some View {
        self.frame(width: w)
            .background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 18, style: .continuous))
            .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
            .overlay(RoundedRectangle(cornerRadius: 18, style: .continuous).stroke(Color.primary.opacity(0.08), lineWidth: 1))
            .shadow(color: .black.opacity(0.04), radius: 10, x: 0, y: 4)
    }
}

/// Transaction ledger - icon, merchant, date, signed amount (credits in green).
struct TableTransactions: View {
    let rows: [(String, String, String, String, Bool)] = [
        ("cart.fill", "Whole Foods", "Jul 22", "−$84.20", false),
        ("arrow.down.circle.fill", "Paycheck", "Jul 21", "+$2,400", true),
        ("fuelpump.fill", "Shell", "Jul 20", "−$52.10", false),
        ("music.note", "Spotify", "Jul 19", "−$10.99", false),
    ]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack(spacing: 12) {
                    Image(systemName: r.0).font(.system(size: 16)).foregroundStyle(.secondary).frame(width: 26)
                    VStack(alignment: .leading, spacing: 2) {
                        Text(r.1).font(.system(size: 15, weight: .medium))
                        Text(r.2).font(.system(size: 12)).foregroundStyle(.secondary)
                    }
                    Spacer()
                    Text(r.3).font(.system(size: 15, weight: .semibold).monospacedDigit()).foregroundStyle(r.4 ? tblGreen : Color.primary)
                }
                .padding(.horizontal, 16).padding(.vertical, 9)
                if i < rows.count - 1 { Divider().padding(.leading, 54) }
            }
        }
        .padding(.vertical, 6)
        .tblCard(330)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17