
Album Grid
From syxUI — written for both platforms, not translated between them.
A grid of album covers with titles.
Cards · SwiftUI · iOS 17
- cards
- swiftui
The actual source
AlbumGrid.swift
// Album Grid · syxUI · https://syxui.dev/components/media2-album-grid
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
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)
}
}
// Album covers grid
struct AlbumGrid: View {
let covers: [(LinearGradient, String, String)] = [
(LinearGradient(colors: [Color(red: 0.55, green: 0.40, blue: 0.85), Color(red: 0.30, green: 0.16, blue: 0.5)], startPoint: .top, endPoint: .bottom), "After Hours", "The Weeknd"),
(LinearGradient(colors: [Color(red: 0.2, green: 0.6, blue: 0.45), Color(red: 0.08, green: 0.3, blue: 0.24)], startPoint: .top, endPoint: .bottom), "Evermore", "Taylor Swift"),
(LinearGradient(colors: [Color(red: 0.98, green: 0.55, blue: 0.10), Color(red: 0.8, green: 0.3, blue: 0.05)], startPoint: .top, endPoint: .bottom), "Positions", "Ariana"),
(LinearGradient(colors: [Color(red: 0.0, green: 0.47, blue: 1.0), Color(red: 0.16, green: 0.18, blue: 0.42)], startPoint: .top, endPoint: .bottom), "Future Nostalgia", "Dua Lipa")]
var body: some View {
VStack(alignment: .leading, spacing: 12) {
Text("Recently played").font(.system(size: 15, weight: .semibold))
LazyVGrid(columns: [GridItem(.flexible(), spacing: 12), GridItem(.flexible(), spacing: 12)], spacing: 12) {
ForEach(Array(covers.enumerated()), id: \.offset) { _, c in
VStack(alignment: .leading, spacing: 5) {
RoundedRectangle(cornerRadius: 8, style: .continuous).fill(c.0).aspectRatio(1, contentMode: .fit)
Text(c.1).font(.system(size: 13, weight: .semibold)).lineLimit(1)
Text(c.2).font(.system(size: 11)).foregroundStyle(.secondary)
}
}
}
}.formaCard().frame(width: 300)
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


