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

Select Rows

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

A single-select list with a checkmark.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

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

import SwiftUI

let listBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

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

// Single-select checkmark row
struct SelectCheckRow: View {
    @State private var sel = 0
    let opts = ["Recommended", "Newest", "Price: Low to High"]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(opts.enumerated()), id: \.offset) { i, o in
                HStack { Text(o).font(.system(size: 15, weight: sel == i ? .semibold : .regular)); Spacer(); if sel == i { Image(systemName: "checkmark").font(.system(size: 14, weight: .bold)).foregroundStyle(listBlue) } }.padding(.vertical, 11).contentShape(Rectangle()).onTapGesture { sel = i }
                if i < opts.count - 1 { Divider() }
            }
        }.formaCard(14).frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17