
Filter Group
From syxUI — written for both platforms, not translated between them.
A filter category that expands into a checkbox list.
Accordions · SwiftUI · iOS 17
- accordion
- swiftui
The actual source
AccFilter.swift
// Filter Group · syxUI · https://syxui.dev/components/acc-filter
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
let accBlue = 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)
}
}
// Filter accordion - category expanded to checkboxes
struct AccFilter: View {
@State private var open = true
@State private var sel: Set<String> = ["Nike", "Adidas"]
let brands = ["Nike", "Adidas", "Puma", "New Balance"]
var body: some View {
VStack(alignment: .leading, spacing: 0) {
HStack {
Text("Brand").font(.system(size: 15, weight: .semibold))
Spacer()
Text("\(sel.count)").font(.system(size: 12, weight: .bold)).foregroundStyle(.white).frame(width: 20, height: 20).background(accBlue, in: Circle())
Image(systemName: "chevron.down").font(.system(size: 12, weight: .semibold)).foregroundStyle(.secondary).rotationEffect(.degrees(open ? 180 : 0)).padding(.leading, 6)
}.padding(.vertical, 13)
if open {
ForEach(brands, id: \.self) { b in
HStack(spacing: 10) {
Image(systemName: sel.contains(b) ? "checkmark.square.fill" : "square").font(.system(size: 18)).foregroundStyle(sel.contains(b) ? accBlue : .secondary)
Text(b).font(.system(size: 15))
Spacer()
}.padding(.vertical, 7)
}
}
}.formaCard(16).frame(width: 320)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17

