Skip to content
Checkbox List preview
Rendered from the SwiftUI source on this page.

Checkbox List

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

A self-contained checkbox list — SwiftUI, styled from system tokens.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

CheckboxListCard.swift
// Checkbox List · syxUI · https://syxui.dev/components/form-checkbox
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

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 list
struct CheckboxListCard: View {
    @State private var sel: Set<Int> = [0, 1]
    let opts = ["Unlimited projects", "Priority support", "Team seats", "Custom domain"]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(opts.indices, id: \.self) { i in
                HStack(spacing: 12) {
                    ZStack {
                        RoundedRectangle(cornerRadius: 6).fill(sel.contains(i) ? Color.primary : .clear).frame(width: 22, height: 22)
                            .overlay(RoundedRectangle(cornerRadius: 6).stroke(sel.contains(i) ? .clear : Color.primary.opacity(0.25), lineWidth: 1.5))
                        if sel.contains(i) { Image(systemName: "checkmark").font(.system(size: 12, weight: .bold)).foregroundStyle(Color(.systemBackground)) }
                    }
                    Text(opts[i]).font(.system(size: 15)).foregroundStyle(.primary)
                    Spacer()
                }.padding(.vertical, 11)
            }
        }.formaCard()
    }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • formaCard

Requires iOS 17