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

Crypto Watchlist

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

Coin rows with badges, price and colored change stacked.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

TableCrypto.swift
// Crypto Watchlist · syxUI · https://syxui.dev/components/table-crypto
// 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)

let tblRed = Color(red: 0.86, green: 0.24, blue: 0.21)

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)
    }
}

func tblBadge(_ initials: String, _ color: Color) -> some View {
    Text(initials).font(.system(size: 10, weight: .bold)).foregroundStyle(.white)
        .frame(width: 26, height: 26).background(Circle().fill(color))
}

/// Crypto watchlist - coin badge, name, price and colored change stacked.
struct TableCrypto: View {
    let rows: [(String, Color, String, String, String, Bool)] = [
        ("B", Color(red: 0.95, green: 0.58, blue: 0.13), "Bitcoin", "$67,240", "+2.4%", true),
        ("E", Color(red: 0.35, green: 0.40, blue: 0.80), "Ethereum", "$3,510", "+1.1%", true),
        ("S", Color(red: 0.55, green: 0.30, blue: 0.85), "Solana", "$142.80", "−3.2%", false),
        ("X", Color(red: 0.12, green: 0.12, blue: 0.14), "XRP", "$0.58", "+0.6%", true),
    ]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack(spacing: 12) {
                    tblBadge(r.0, r.1)
                    Text(r.2).font(.system(size: 15, weight: .medium)).frame(maxWidth: .infinity, alignment: .leading)
                    VStack(alignment: .trailing, spacing: 2) {
                        Text(r.3).font(.system(size: 14, weight: .semibold).monospacedDigit())
                        Text(r.4).font(.system(size: 12, weight: .medium).monospacedDigit()).foregroundStyle(r.5 ? tblGreen : tblRed)
                    }
                }
                .padding(.horizontal, 16).padding(.vertical, 10)
                if i < rows.count - 1 { Divider().padding(.leading, 54) }
            }
        }
        .padding(.vertical, 4)
        .tblCard(320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17