
Amount Selector
From syxUI — written for both platforms, not translated between them.
Preset amount chips with a custom-amount row.
Inputs · SwiftUI · iOS 17
- inputs
- swiftui
The actual source
AmountSelectorCard.swift
// Amount Selector · syxUI · https://syxui.dev/components/sel-amount
// 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)
}
}
// Preset amount selector
struct AmountSelectorCard: View {
@State private var sel = 1
let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
let amounts = ["$10", "$25", "$50", "$100"]
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Choose an amount").font(.system(size: 15, weight: .semibold))
HStack(spacing: 10) {
ForEach(Array(amounts.enumerated()), id: \.offset) { i, a in
let on = sel == i
Text(a).font(.system(size: 15, weight: .semibold)).foregroundStyle(on ? .white : .primary)
.frame(maxWidth: .infinity).padding(.vertical, 14)
.background(on ? blue : Color.primary.opacity(0.05), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
.onTapGesture { sel = i }
}
}
HStack {
Text("Custom amount").font(.system(size: 14)).foregroundStyle(.secondary)
Spacer()
Image(systemName: "chevron.right").font(.system(size: 12, weight: .semibold)).foregroundStyle(.secondary)
}.padding(.top, 2)
}.formaCard().frame(width: 330)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


