
Radio Group
From syxUI — written for both platforms, not translated between them.
A self-contained radio group — SwiftUI, styled from system tokens.
Inputs · SwiftUI · iOS 17
- inputs
- swiftui
The actual source
RadioGroupCard.swift
// Radio Group · syxUI · https://syxui.dev/components/form-radio
// 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)
}
}
// Radio group
struct RadioGroupCard: View {
@State private var sel = 1
let opts = [("Free", "For getting started"), ("Pro", "$12/mo · everything unlocked"), ("Team", "$8/seat · for teams")]
var body: some View {
VStack(spacing: 10) {
ForEach(opts.indices, id: \.self) { i in
HStack(spacing: 12) {
ZStack {
Circle().stroke(sel == i ? Color.primary : Color.primary.opacity(0.25), lineWidth: 1.8).frame(width: 22, height: 22)
if sel == i { Circle().fill(Color.primary).frame(width: 12, height: 12) }
}
VStack(alignment: .leading, spacing: 1) {
Text(opts[i].0).font(.system(size: 15, weight: .semibold))
Text(opts[i].1).font(.system(size: 12)).foregroundStyle(.secondary)
}
Spacer()
}
.padding(14)
.overlay(RoundedRectangle(cornerRadius: 14).stroke(sel == i ? Color.primary : Color.primary.opacity(0.12), lineWidth: sel == i ? 1.6 : 1))
}
}.formaCard()
}
}
iOS 17 · 1 dependencies
Dependencies
- SwiftUI
- formaCard
Requires iOS 17


