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

Balance Card

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

A finance balance card with change % and send / receive actions.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

BalanceCard.swift
// Balance Card · syxUI · https://syxui.dev/components/card-balance
// 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)
    }
}

// Balance / finance card
struct BalanceCard: View {
    let green = Color(red: 0.16, green: 0.66, blue: 0.40)
    var body: some View {
        VStack(alignment: .leading, spacing: 14) {
            VStack(alignment: .leading, spacing: 4) {
                Text("Total Balance").font(.system(size: 13)).foregroundStyle(.secondary)
                HStack(alignment: .firstTextBaseline, spacing: 8) {
                    Text("$24,680").font(.system(size: 28, weight: .bold))
                    HStack(spacing: 2) {
                        Image(systemName: "arrow.up.right").font(.system(size: 10, weight: .bold))
                        Text("3.2%").font(.system(size: 12, weight: .semibold))
                    }.foregroundStyle(green)
                }
            }
            HStack(spacing: 10) {
                actionBtn("arrow.up", "Send")
                actionBtn("arrow.down", "Receive")
            }
        }.formaCard().frame(width: 280)
    }
    func actionBtn(_ icon: String, _ label: String) -> some View {
        HStack(spacing: 6) {
            Image(systemName: icon).font(.system(size: 13, weight: .semibold))
            Text(label).font(.system(size: 14, weight: .medium))
        }
        .foregroundStyle(.primary).frame(maxWidth: .infinity).padding(.vertical, 10)
        .background(Color.primary.opacity(0.05), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17