
Category Pills
From syxUI — written for both platforms, not translated between them.
A row of category pills with one active.
Inputs · SwiftUI · iOS 17
- inputs
- swiftui
The actual source
CategoryPillsCard.swift
// Category Pills · syxUI · https://syxui.dev/components/sel-category-pills
// 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)
}
}
// Category pill selector
struct CategoryPillsCard: View {
@State private var sel = 1
let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
let cats = ["All", "Trending", "New", "Deals"]
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Browse").font(.system(size: 15, weight: .semibold))
HStack(spacing: 8) {
ForEach(Array(cats.enumerated()), id: \.offset) { i, c in
let on = sel == i
Text(c).font(.system(size: 14, weight: on ? .semibold : .medium)).foregroundStyle(on ? .white : .primary)
.padding(.horizontal, 15).padding(.vertical, 8)
.background(on ? blue : Color.primary.opacity(0.06), in: Capsule())
.onTapGesture { sel = i }
}
}
}.formaCard().frame(width: 340)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


