
Multi-Open
From syxUI — written for both platforms, not translated between them.
An accordion allowing several sections open at once.
Accordions · SwiftUI · iOS 17
- accordion
- swiftui
The actual source
AccMultiOpen.swift
// Multi-Open · syxUI · https://syxui.dev/components/acc-multi-open
// 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)
}
}
// Multi-open accordion (two sections open)
struct AccMultiOpen: View {
@State private var open: Set<Int> = [0, 1]
let qs = [("Free plan", "Up to 3 projects and basic analytics."),
("Pro plan", "Unlimited projects, priority support, advanced analytics."),
("Enterprise", "Custom limits, SSO and a dedicated manager.")]
var body: some View {
VStack(spacing: 0) {
ForEach(Array(qs.enumerated()), id: \.offset) { i, q in
HStack {
Text(q.0).font(.system(size: 15, weight: .medium))
Spacer()
Image(systemName: open.contains(i) ? "minus.circle.fill" : "plus.circle.fill").font(.system(size: 18)).foregroundStyle(open.contains(i) ? accBlue : .secondary)
}.padding(.vertical, 13).contentShape(Rectangle()).onTapGesture { if open.contains(i) { open.remove(i) } else { open.insert(i) } }
if open.contains(i) { Text(q.1).font(.system(size: 14)).foregroundStyle(.secondary).frame(maxWidth: .infinity, alignment: .leading).padding(.bottom, 13) }
if i < qs.count - 1 { Divider() }
}
}.formaCard(16).frame(width: 340)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17

