
Selectable Rows
From syxUI — written for both platforms, not translated between them.
Multi-select rows with checkboxes and a tinted selected state.
Cards · SwiftUI · iOS 17
- cards
- swiftui
The actual source
TableSelectable.swift
// Selectable Rows · syxUI · https://syxui.dev/components/table-selectable
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
let tblBlue = Color(red: 0.0, green: 0.47, blue: 1.0)
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)
}
}
/// Multi-select table - checkbox column, selected rows tinted.
struct TableSelectable: View {
let rows: [(String, String, Bool)] = [
("Invoice #1042", "Paid", true), ("Invoice #1043", "Pending", true),
("Invoice #1044", "Paid", false), ("Invoice #1045", "Overdue", false),
]
var body: some View {
VStack(spacing: 0) {
ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
HStack(spacing: 12) {
Image(systemName: r.2 ? "checkmark.square.fill" : "square")
.font(.system(size: 18)).foregroundStyle(r.2 ? tblBlue : Color.secondary.opacity(0.5))
Text(r.0).font(.system(size: 14, weight: .medium)).frame(maxWidth: .infinity, alignment: .leading)
Text(r.1).font(.system(size: 12)).foregroundStyle(.secondary)
}
.padding(.horizontal, 16).padding(.vertical, 12)
.background(r.2 ? tblBlue.opacity(0.05) : Color.clear)
if i < rows.count - 1 { Divider().padding(.leading, 46) }
}
}
.tblCard(320)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


