Skip to content
Status Table preview
Rendered from the SwiftUI source on this page.

Status Table

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

Rows with a health dot and a colored status pill.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

TableStatusRows.swift
// Status Table · syxUI · https://syxui.dev/components/table-status
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let tblGreen = Color(red: 0.13, green: 0.62, blue: 0.32)

let tblRed = Color(red: 0.86, green: 0.24, blue: 0.21)

extension View {
    func tblCard(_ w: CGFloat) -> some View {
        self.frame(width: w)
            .background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 18, style: .continuous))
            .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
            .overlay(RoundedRectangle(cornerRadius: 18, style: .continuous).stroke(Color.primary.opacity(0.08), lineWidth: 1))
            .shadow(color: .black.opacity(0.04), radius: 10, x: 0, y: 4)
    }
}

func tblPill(_ text: String, _ color: Color) -> some View {
    Text(text).font(.system(size: 11, weight: .semibold)).foregroundStyle(color)
        .padding(.horizontal, 8).padding(.vertical, 3)
        .background(color.opacity(0.14), in: Capsule())
}

/// Service status table - health dot, name, colored status pill.
struct TableStatusRows: View {
    let rows: [(String, String, Color)] = [
        ("api-gateway", "Active", tblGreen), ("auth-service", "Warning", Color(red: 0.90, green: 0.62, blue: 0.10)),
        ("payments", "Failed", tblRed), ("search-index", "Active", tblGreen),
    ]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack {
                    Circle().fill(r.2).frame(width: 8, height: 8)
                    Text(r.0).font(.system(size: 14, weight: .medium)).frame(maxWidth: .infinity, alignment: .leading)
                    tblPill(r.1, r.2)
                }
                .padding(.horizontal, 16).padding(.vertical, 12)
                if i < rows.count - 1 { Divider().padding(.leading, 16) }
            }
        }
        .tblCard(320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17