Skip to content
Help Center preview
Rendered from the SwiftUI source on this page.

Help Center

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

A help category that expands into linked articles.

Accordions · SwiftUI · iOS 17

  • accordion
  • swiftui

The actual source

AccHelp.swift
// Help Center · syxUI · https://syxui.dev/components/acc-help
// 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)
    }
}

// Help center accordion
struct AccHelp: View {
    @State private var open = true
    let articles = ["How to reset your password", "Managing notifications", "Deleting your account"]
    var body: some View {
        VStack(alignment: .leading, spacing: 0) {
            HStack(spacing: 12) {
                Image(systemName: "questionmark.circle.fill").font(.system(size: 18)).foregroundStyle(accBlue)
                Text("Getting Started").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 {
                ForEach(articles, id: \.self) { a in
                    Divider()
                    HStack {
                        Image(systemName: "doc.text").font(.system(size: 13)).foregroundStyle(.secondary)
                        Text(a).font(.system(size: 14))
                        Spacer()
                        Image(systemName: "chevron.right").font(.system(size: 11, weight: .semibold)).foregroundStyle(.secondary.opacity(0.5))
                    }.padding(.vertical, 11)
                }
            }
        }.formaCard(16).frame(width: 340)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17