Skip to content
Spec Sheet preview
Rendered from the SwiftUI source on this page.

Spec Sheet

From syxUI — written for both platforms, not translated between them.

A specifications accordion with key / value rows.

Accordions · SwiftUI · iOS 17

  • accordion
  • swiftui

The actual source

AccSpecs.swift
// Spec Sheet · syxUI · https://syxui.dev/components/acc-specs
// 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)
    }
}

// Product specifications accordion
struct AccSpecs: View {
    @State private var open = true
    let specs = [("Display", "6.7\" OLED"), ("Chip", "A18 Pro"), ("Storage", "256 GB"), ("Battery", "4,400 mAh")]
    var body: some View {
        VStack(spacing: 0) {
            HStack {
                Text("Specifications").font(.system(size: 15, weight: .semibold))
                Spacer()
                Image(systemName: "chevron.down").font(.system(size: 12, weight: .semibold)).foregroundStyle(.secondary).rotationEffect(.degrees(open ? 180 : 0))
            }.padding(.vertical, 13)
            if open {
                Divider()
                ForEach(Array(specs.enumerated()), id: \.offset) { i, s in
                    HStack {
                        Text(s.0).font(.system(size: 14)).foregroundStyle(.secondary)
                        Spacer()
                        Text(s.1).font(.system(size: 14, weight: .medium))
                    }.padding(.vertical, 9)
                    if i < specs.count - 1 { Divider() }
                }
            }
        }.formaCard(16).frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17