
Expandable Card
From syxUI — written for both platforms, not translated between them.
A card that expands to reveal details and an action.
Accordions · SwiftUI · iOS 17
- accordion
- swiftui
The actual source
AccCard.swift
// Expandable Card · syxUI · https://syxui.dev/components/acc-card
// 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)
}
}
// Expandable card with icon + action
struct AccCard: View {
@State private var open = true
let purple = Color(red: 0.55, green: 0.40, blue: 0.90)
var body: some View {
VStack(alignment: .leading, spacing: 12) {
HStack(spacing: 12) {
Image(systemName: "sparkles").font(.system(size: 16)).foregroundStyle(purple).frame(width: 38, height: 38).background(purple.opacity(0.12), in: RoundedRectangle(cornerRadius: 10))
VStack(alignment: .leading, spacing: 2) {
Text("What's new in 2.0").font(.system(size: 15, weight: .semibold))
Text("Tap to expand").font(.system(size: 12)).foregroundStyle(.secondary)
}
Spacer()
Image(systemName: "chevron.down").font(.system(size: 13, weight: .semibold)).foregroundStyle(.secondary).rotationEffect(.degrees(open ? 180 : 0))
}
if open {
Text("A redesigned home, faster sync, and a brand-new widget. Update now to try everything.").font(.system(size: 14)).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)
Text("See details").font(.system(size: 14, weight: .semibold)).foregroundStyle(purple)
}
}.formaCard().frame(width: 320)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17

