
Avatar Grid
From syxUI — written for both platforms, not translated between them.
A selectable avatar grid.
Avatars · SwiftUI · iOS 17
- avatars
- swiftui
The actual source
AvatarGrid.swift
// Avatar Grid · syxUI · https://syxui.dev/components/avatar-grid
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
let avBlue = Color(red: 0.0, green: 0.47, blue: 1.0)
func av(_ name: String, _ d: CGFloat) -> some View { Image(name).resizable().scaledToFill().frame(width: d, height: d).clipShape(Circle()) }
struct AvatarGrid: View { private let people = ["person_1", "person_2", "person_3", "person_4", "person_5", "person_1"]; var body: some View { LazyVGrid(columns: Array(repeating: GridItem(.flexible(), spacing: 14), count: 3), spacing: 14) { ForEach(Array(people.enumerated()), id: \.offset) { i, p in av(p, 60).padding(i == 0 ? 3 : 0).overlay { if i == 0 { Circle().stroke(avBlue, lineWidth: 2.5) } }.overlay(alignment: .bottomTrailing) { if i == 0 { Image(systemName: "checkmark.circle.fill").font(.system(size: 18)).foregroundStyle(avBlue).background(Circle().fill(.white).frame(width: 16, height: 16)) } } } }.frame(width: 260) } }
iOS 17 · 5 dependencies
Dependencies
- SwiftUI
- person_1 (image asset)
- person_2 (image asset)
- person_3 (image asset)
- person_4 (image asset)
- person_5 (image asset)
Requires iOS 17