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

Badge Avatars

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

Avatars with small icon badges.

Avatars · SwiftUI · iOS 17

  • avatars
  • swiftui

The actual source

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

import SwiftUI

let avPurple = Color(red: 0.55, green: 0.40, blue: 0.90)
let avOrange = Color(red: 0.98, green: 0.55, blue: 0.10)

func av(_ name: String, _ d: CGFloat) -> some View { Image(name).resizable().scaledToFill().frame(width: d, height: d).clipShape(Circle()) }

struct AvatarBadgeIcon: View { var body: some View { HStack(spacing: 16) { av("person_3", 56).overlay(alignment: .bottomTrailing) { Image(systemName: "star.fill").font(.system(size: 10)).foregroundStyle(.white).frame(width: 20, height: 20).background(avOrange, in: Circle()).overlay(Circle().stroke(Color(.systemBackground), lineWidth: 2)) }; av("person_4", 56).overlay(alignment: .bottomTrailing) { Image(systemName: "crown.fill").font(.system(size: 9)).foregroundStyle(.white).frame(width: 20, height: 20).background(avPurple, in: Circle()).overlay(Circle().stroke(Color(.systemBackground), lineWidth: 2)) } } } }
iOS 17 · 2 dependencies

Dependencies

SwiftUI
  • person_3 (image asset)
  • person_4 (image asset)

Requires iOS 17