Skip to content
Checklist Rows preview
Rendered from the SwiftUI source on this page.

Checklist Rows

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

A checklist with completed rows struck through.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

CheckboxRow.swift
// Checklist Rows · syxUI · https://syxui.dev/components/list-checkbox
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let listGreen = Color(red: 0.20, green: 0.78, blue: 0.35)

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

// Checkbox row
struct CheckboxRow: View {
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array([("Buy groceries", true), ("Call the dentist", true), ("Finish the report", false)].enumerated()), id: \.offset) { i, t in
                HStack(spacing: 12) {
                    Image(systemName: t.1 ? "checkmark.circle.fill" : "circle").font(.system(size: 20)).foregroundStyle(t.1 ? listGreen : .secondary.opacity(0.5))
                    Text(t.0).font(.system(size: 15)).strikethrough(t.1).foregroundStyle(t.1 ? .secondary : .primary)
                    Spacer()
                }.padding(.vertical, 9)
                if i < 2 { Divider().padding(.leading, 32) }
            }
        }.formaCard(14).frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17