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

Comparison Table

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

A feature-by-plan matrix with check and cross marks.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

TableCompare.swift
// Comparison Table · syxUI · https://syxui.dev/components/table-compare
// 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)
    }
}

/// Feature × plan comparison matrix with check / cross marks (Monzo Compare).
struct TableCompare: View {
    let features = ["Virtual cards", "Custom categories", "Auto-savings", "Priority support"]
    let plans = ["Free", "Plus", "Pro", "Max"]
    let grid: [[Bool]] = [
        [false, true, true, true], [false, true, true, true],
        [false, false, true, true], [false, false, false, true],
    ]
    var body: some View {
        VStack(spacing: 0) {
            HStack(spacing: 0) {
                Text("Features").font(.system(size: 12, weight: .semibold)).foregroundStyle(.secondary)
                    .frame(maxWidth: .infinity, alignment: .leading)
                ForEach(Array(plans.enumerated()), id: \.offset) { _, p in
                    Text(p).font(.system(size: 12, weight: .semibold)).frame(width: 46)
                }
            }
            .padding(.horizontal, 16).padding(.vertical, 11)
            Divider()
            ForEach(Array(features.enumerated()), id: \.offset) { i, f in
                HStack(spacing: 0) {
                    Text(f).font(.system(size: 13)).frame(maxWidth: .infinity, alignment: .leading)
                    ForEach(Array(grid[i].enumerated()), id: \.offset) { _, has in
                        Image(systemName: has ? "checkmark" : "xmark")
                            .font(.system(size: 12, weight: .semibold))
                            .foregroundStyle(has ? tblGreen : Color.secondary.opacity(0.4))
                            .frame(width: 46)
                    }
                }
                .padding(.horizontal, 16).padding(.vertical, 11)
                if i < features.count - 1 { Divider().padding(.leading, 16) }
            }
        }
        .tblCard(340)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17