Skip to content
Badge Rows preview
Rendered from the SwiftUI source on this page.

Badge Rows

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

Rows with count badges and chevrons.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

BadgeRow.swift
// Badge Rows · syxUI · https://syxui.dev/components/list-badge
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let listBlue = 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)
    }
}

// Row with count badge
struct BadgeRow: View {
    let rows: [(String, String, Int)] = [("tray.fill", "Inbox", 12), ("paperplane.fill", "Sent", 0), ("exclamationmark.triangle.fill", "Spam", 3)]
    var body: some View {
        VStack(spacing: 0) {
            ForEach(Array(rows.enumerated()), id: \.offset) { i, r in
                HStack(spacing: 12) { Image(systemName: r.0).font(.system(size: 15)).foregroundStyle(listBlue).frame(width: 24); Text(r.1).font(.system(size: 15)); Spacer(); if r.2 > 0 { Text("\(r.2)").font(.system(size: 12, weight: .semibold)).foregroundStyle(.white).padding(.horizontal, 7).padding(.vertical, 2).frame(minWidth: 22).background(listBlue, in: Capsule()) }; Image(systemName: "chevron.right").font(.system(size: 12, weight: .semibold)).foregroundStyle(.secondary.opacity(0.5)) }.padding(.vertical, 10)
                if i < rows.count - 1 { Divider().padding(.leading, 36) }
            }
        }.formaCard(14).frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17