Skip to content
Radio Cards preview
Rendered from the SwiftUI source on this page.

Radio Cards

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

Vertical option cards with a radio dot - shipping / delivery style.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

RadioCardsCard.swift
// Radio Cards · syxUI · https://syxui.dev/components/sel-radio-cards
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Radio option cards (shipping style)
struct RadioCardsCard: View {
    @State private var sel = 0
    let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
    let opts = [("Standard", "3–5 business days", "Free"), ("Express", "1–2 business days", "$9.99"), ("Overnight", "Next business day", "$24.99")]
    var body: some View {
        VStack(spacing: 10) {
            ForEach(Array(opts.enumerated()), id: \.offset) { i, o in
                let on = sel == i
                HStack(spacing: 12) {
                    Circle().stroke(on ? blue : Color.primary.opacity(0.25), lineWidth: on ? 6 : 1.5).frame(width: 20, height: 20)
                    VStack(alignment: .leading, spacing: 2) {
                        Text(o.0).font(.system(size: 15, weight: .semibold))
                        Text(o.1).font(.system(size: 12)).foregroundStyle(.secondary)
                    }
                    Spacer()
                    Text(o.2).font(.system(size: 14, weight: .semibold))
                }
                .padding(14)
                .background(on ? blue.opacity(0.06) : .clear, in: RoundedRectangle(cornerRadius: 14, style: .continuous))
                .overlay(RoundedRectangle(cornerRadius: 14, style: .continuous).stroke(on ? blue : Color.primary.opacity(0.12), lineWidth: on ? 2 : 1))
                .contentShape(Rectangle()).onTapGesture { sel = i }
            }
        }.frame(width: 330)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17