Skip to content
Trend Badges preview
Rendered from the SwiftUI source on this page.

Trend Badges

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

Up / down percentage badges.

Badges · SwiftUI · iOS 17

  • badges
  • swiftui

The actual source

PercentageBadges.swift
// Trend Badges · syxUI · https://syxui.dev/components/tag-percentage
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let tgGreen = Color(red: 0.16, green: 0.66, blue: 0.40)
let tgRed = Color(red: 0.90, green: 0.24, blue: 0.28)

// Percentage badges
struct PercentageBadges: View {
    var body: some View {
        HStack(spacing: 8) {
            HStack(spacing: 3) { Image(systemName: "arrow.up.right").font(.system(size: 10, weight: .bold)); Text("12.4%").font(.system(size: 13, weight: .semibold)) }.foregroundStyle(tgGreen).padding(.horizontal, 9).padding(.vertical, 5).background(tgGreen.opacity(0.14), in: Capsule())
            HStack(spacing: 3) { Image(systemName: "arrow.down.right").font(.system(size: 10, weight: .bold)); Text("3.1%").font(.system(size: 13, weight: .semibold)) }.foregroundStyle(tgRed).padding(.horizontal, 9).padding(.vertical, 5).background(tgRed.opacity(0.14), in: Capsule())
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17