Skip to content
Notification Card preview
Rendered from the SwiftUI source on this page.

Notification Card

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

A notification row - icon, title, message, time and unread dot.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

NotificationCard.swift
// Notification Card · syxUI · https://syxui.dev/components/card-notification
// 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)
    }
}

// Notification card
struct NotificationCard: View {
    var body: some View {
        HStack(spacing: 12) {
            Image(systemName: "bell.badge.fill").font(.system(size: 16)).foregroundStyle(.white)
                .frame(width: 40, height: 40).background(Color(red: 0.0, green: 0.47, blue: 1.0), in: RoundedRectangle(cornerRadius: 10, style: .continuous))
            VStack(alignment: .leading, spacing: 3) {
                HStack {
                    Text("New comment").font(.system(size: 15, weight: .semibold))
                    Spacer()
                    Text("2m").font(.system(size: 12)).foregroundStyle(.secondary)
                }
                Text("James replied to your post").font(.system(size: 13)).foregroundStyle(.secondary).lineLimit(1)
            }
            Circle().fill(Color(red: 0.0, green: 0.47, blue: 1.0)).frame(width: 8, height: 8)
        }.formaCard(14).frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17