Skip to content
Share Sheet preview
Rendered from the SwiftUI source on this page.

Share Sheet

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

A share sheet with app targets.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

ShareSheet.swift
// Share Sheet · syxUI · https://syxui.dev/components/sheet-share
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let shBlue = Color(red: 0.0, green: 0.47, blue: 1.0)
let shGreen = Color(red: 0.16, green: 0.66, blue: 0.40)

func shCard<C: View>(_ w: CGFloat, radius: CGFloat = 18, @ViewBuilder _ c: () -> C) -> some View {
    c().frame(width: w).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: radius, style: .continuous)).overlay(RoundedRectangle(cornerRadius: radius, style: .continuous).stroke(Color.primary.opacity(0.07), lineWidth: 1)).shadow(color: .black.opacity(0.05), radius: 12, y: 5)
}

// Share sheet
struct ShareSheet: View {
    let apps: [(String, Color)] = [("message.fill", shGreen), ("envelope.fill", shBlue), ("bubble.left.fill", Color(red: 0.36, green: 0.42, blue: 0.9)), ("link", .gray)]
    var body: some View {
        shCard(340, radius: 22) {
            VStack(alignment: .leading, spacing: 16) {
                Capsule().fill(Color.primary.opacity(0.2)).frame(width: 36, height: 5).frame(maxWidth: .infinity)
                HStack(spacing: 18) {
                    ForEach(Array(apps.enumerated()), id: \.offset) { _, a in
                        VStack(spacing: 6) { Image(systemName: a.0).font(.system(size: 22)).foregroundStyle(.white).frame(width: 56, height: 56).background(a.1, in: RoundedRectangle(cornerRadius: 14, style: .continuous)); Text("App").font(.system(size: 11)).foregroundStyle(.secondary) }
                    }
                }
                Divider()
                HStack { Image(systemName: "square.and.arrow.up").font(.system(size: 16)); Text("Save to Files").font(.system(size: 15)); Spacer() }.foregroundStyle(.primary)
            }.padding(18)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17