Skip to content
Numbered Steps preview
Rendered from the SwiftUI source on this page.

Numbered Steps

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

A numbered step list where the active step expands.

Accordions · SwiftUI · iOS 17

  • accordion
  • swiftui

The actual source

AccNumbered.swift
// Numbered Steps · syxUI · https://syxui.dev/components/acc-numbered
// 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)
    }
}

// Numbered steps accordion
struct AccNumbered: View {
    @State private var open = 1
    let steps = [("Create your account", "Sign up with email or Apple in seconds."),
                         ("Set up your profile", "Add a photo, bio and your interests so we can personalize things."),
                         ("Invite your team", "Share a link and start collaborating.")]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(steps.enumerated()), id: \.offset) { i, s in
                HStack(alignment: .top, spacing: 12) {
                    Text("\(i + 1)").font(.system(size: 13, weight: .bold)).foregroundStyle(open == i ? .white : .secondary).frame(width: 26, height: 26).background(open == i ? accBlue : Color.primary.opacity(0.08), in: Circle())
                    VStack(alignment: .leading, spacing: 4) {
                        Text(s.0).font(.system(size: 15, weight: .medium))
                        if open == i { Text(s.1).font(.system(size: 13)).foregroundStyle(.secondary) }
                    }
                    Spacer()
                }.padding(.vertical, 10).contentShape(Rectangle()).onTapGesture { open = i }
            }
        }.formaCard(16).frame(width: 330)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17