Skip to content
Link Preview preview
Rendered from the SwiftUI source on this page.

Link Preview

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

A message with a rich link card - image, title and domain.

Chat · SwiftUI · iOS 17

  • chat
  • swiftui

The actual source

ChatLinkPreview.swift
// Link Preview · syxUI · https://syxui.dev/components/chat-link-preview
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Link preview bubble
struct ChatLinkPreview: View {
    var body: some View {
        HStack {
            VStack(alignment: .leading, spacing: 0) {
                Image("photo_travel").resizable().scaledToFill().frame(width: 240, height: 130).clipped()
                VStack(alignment: .leading, spacing: 3) {
                    Text("The 10 Best Islands to Visit in Greece").font(.system(size: 14, weight: .semibold)).lineLimit(2)
                    Text("travelmag.com").font(.system(size: 12)).foregroundStyle(.secondary)
                }
                .padding(.horizontal, 12).padding(.vertical, 10).frame(width: 240, alignment: .leading)
            }
            .background(Color(.systemGray6))
            .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous))
            Spacer(minLength: 20)
        }
    }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • photo_travel (image asset)

Requires iOS 17