Components
Profile
The person, their stats and their account. Built in all 5 Effect UI styles, in light and dark mode.










Source: Ledger
ProfileView.swift in the free Ledger style. It needs Ledger's Theme.swift, which comes with the style: join early access on the home page and it's emailed to you.
import SwiftUI
private struct LinkedAccount: Identifiable {
let id = UUID()
let institution: String
let monogram: String
let kind: String
let mask: String
let synced: String
let balance: Double
}
private let linkedAccounts: [LinkedAccount] = [
LinkedAccount(institution: "Chase", monogram: "CH", kind: "Total Checking", mask: "4821", synced: "2h ago", balance: 8412.36),
LinkedAccount(institution: "Ally Bank", monogram: "AL", kind: "Online Savings", mask: "0937", synced: "2h ago", balance: 15906.26),
LinkedAccount(institution: "Fidelity", monogram: "FI", kind: "Brokerage", mask: "5520", synced: "Yesterday", balance: 190551.50),
LinkedAccount(institution: "American Express", monogram: "AX", kind: "Gold Card", mask: "1004", synced: "4h ago", balance: -2184.90),
LinkedAccount(institution: "Toyota Financial", monogram: "TF", kind: "Auto loan", mask: "7713", synced: "Nov 25", balance: -26264.85),
]
private let netWorthTrend: [Double] = [
171_204, 173_018, 172_436, 175_912, 177_305, 176_118,
179_840, 181_226, 180_514, 182_508, 184_930, 186_420.37,
]
struct ProfileView: View {
private var assets: Double { linkedAccounts.filter { $0.balance > 0 }.reduce(0) { $0 + $1.balance } }
private var liabilities: Double { linkedAccounts.filter { $0.balance < 0 }.reduce(0) { $0 + $1.balance } }
var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: Theme.Space.xxl) {
ScreenHeader(eyebrow: "Account", title: "Profile") {
Button("Edit") {}
.buttonStyle(TextButtonStyle(color: Theme.onSurface))
}
identity
netWorthCard
accountsSection
detailsSection
Button("Sign out") {}
.buttonStyle(.ledgerSecondary)
}
.padding(.horizontal, Theme.Space.margin)
.padding(.top, Theme.Space.sm)
.padding(.bottom, Theme.Space.xxl)
}
.scrollIndicators(.hidden)
.paperBackground()
}
private var identity: some View {
HStack(spacing: Theme.Space.lg) {
Avatar(initials: "MO", size: 64)
VStack(alignment: .leading, spacing: Theme.Space.xs) {
Text("Maya Okafor")
.ledgerType(.headlineMd)
.foregroundStyle(Theme.onSurface)
Text("Member since March 2023")
.ledgerType(.bodySm)
.foregroundStyle(Theme.onSurfaceVariant)
Tag("Plus · Yearly").padding(.top, Theme.Space.xxs)
}
Spacer()
}
}
private var netWorthCard: some View {
VStack(alignment: .leading, spacing: Theme.Space.lg) {
BalanceHero(
label: "Net worth",
amount: assets + liabilities,
delta: 3912.44,
percent: 2.1,
period: "30 days",
showsRule: false
)
LedgerLineChart(
values: netWorthTrend,
labels: ["Dec", "Mar", "Jun", "Sep", "Nov"],
height: 84,
zeroBaseline: false
)
Hairline()
HStack(alignment: .top, spacing: Theme.Space.lg) {
summaryColumn(label: "Assets", value: assets, count: "3 accounts")
Rectangle().fill(Theme.rule).frame(width: 0.5)
summaryColumn(label: "Liabilities", value: liabilities, count: "2 accounts")
}
.fixedSize(horizontal: false, vertical: true)
}
.ledgerCard()
}
private func summaryColumn(label: String, value: Double, count: String) -> some View {
VStack(alignment: .leading, spacing: Theme.Space.xs) {
MicroLabel(label)
Text(Money.format(value, decimals: 2))
.ledgerType(.numeralMd)
.foregroundStyle(Theme.onSurface)
.lineLimit(1)
.minimumScaleFactor(0.8)
Text(count)
.ledgerType(.bodySm)
.foregroundStyle(Theme.onSurfaceMuted)
}
.frame(maxWidth: .infinity, alignment: .leading)
}
private var accountsSection: some View {
VStack(alignment: .leading, spacing: 0) {
SectionHeader(title: "Connected banks", detail: "5 accounts")
RuledStack(closed: true) {
ForEach(linkedAccounts) { a in
LedgerRow(title: a.institution, subtitle: "\(a.kind) ••\(a.mask) · \(a.synced)") {
MonogramTile(letters: a.monogram)
} trailing: {
AmountText(value: a.balance)
}
}
}
Button {
} label: {
Label("Add account", systemImage: "plus")
}
.buttonStyle(TextButtonStyle(color: Theme.primaryInk))
.padding(.top, Theme.Space.xs)
}
}
private var detailsSection: some View {
VStack(alignment: .leading, spacing: 0) {
SectionHeader(title: "Account details")
RuledStack {
detailRow("Email", "maya.okafor@fastmail.com")
detailRow("Phone", "+1 (415) 555-0142")
detailRow("Home currency", "USD · US dollar")
detailRow("Plan", "Tilde Plus, yearly")
detailRow("Renews", "Mar 14, 2027")
}
}
}
private func detailRow(_ title: String, _ value: String) -> some View {
LedgerRow(title: title) {
Text(value)
.ledgerType(.bodyMd)
.foregroundStyle(Theme.onSurfaceVariant)
.lineLimit(1)
.truncationMode(.middle)
}
}
}
#Preview("Light") {
ProfileView()
}
#Preview("Dark") {
ProfileView().preferredColorScheme(.dark)
}
More screens





