Skip to content
File Attachment preview
Rendered from the SwiftUI source on this page.

File Attachment

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

A document message with a file icon, name and size.

Chat · SwiftUI · iOS 17

  • chat
  • swiftui

The actual source

ChatFileAttachment.swift
// File Attachment · syxUI · https://syxui.dev/components/chat-file
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// File attachment bubble
struct ChatFileAttachment: View {
    var body: some View {
        HStack {
            HStack(spacing: 12) {
                Image(systemName: "doc.fill").font(.system(size: 22)).foregroundStyle(Color(red: 0.9, green: 0.24, blue: 0.22))
                    .frame(width: 44, height: 44).background(Color.primary.opacity(0.05), in: RoundedRectangle(cornerRadius: 10))
                VStack(alignment: .leading, spacing: 2) {
                    Text("Q3_Proposal.pdf").font(.system(size: 15, weight: .medium))
                    Text("2.4 MB · PDF").font(.system(size: 12)).foregroundStyle(.secondary)
                }
                Image(systemName: "arrow.down.circle").font(.system(size: 20)).foregroundStyle(.secondary)
            }
            .padding(12)
            .background(Color(.systemGray5), in: RoundedRectangle(cornerRadius: 18, style: .continuous))
            Spacer(minLength: 30)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17