
Order Summary
From syxUI — written for both platforms, not translated between them.
An expandable order summary with line items and total.
Accordions · SwiftUI · iOS 17
- accordion
- swiftui
The actual source
AccOrder.swift
// Order Summary · syxUI · https://syxui.dev/components/acc-order
// 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)
}
}
// Order summary accordion
struct AccOrder: View {
@State private var open = true
let items = [("Wireless Headphones", "$199"), ("USB-C Cable", "$19"), ("AppleCare+", "$29")]
var body: some View {
VStack(spacing: 0) {
HStack {
Text("Order Summary").font(.system(size: 15, weight: .semibold))
Spacer()
Text("$247").font(.system(size: 15, weight: .semibold))
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 {
Divider().padding(.bottom, 4)
ForEach(Array(items.enumerated()), id: \.offset) { _, it in
HStack {
Text(it.0).font(.system(size: 14)).foregroundStyle(.secondary)
Spacer()
Text(it.1).font(.system(size: 14))
}.padding(.vertical, 6)
}
Divider().padding(.vertical, 4)
HStack { Text("Total").font(.system(size: 15, weight: .bold)); Spacer(); Text("$247").font(.system(size: 15, weight: .bold)) }
}
}.formaCard(16).frame(width: 320)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17

