
Context Menu
From syxUI — written for both platforms, not translated between them.
An iOS-style context menu.
Cards · SwiftUI · iOS 17
- cards
- swiftui
The actual source
ContextMenu.swift
// Context Menu · syxUI · https://syxui.dev/components/sheet-menu
// Free in any project. Keep this line and credit syxUI where a person can read it.
import SwiftUI
let shRed = Color(red: 0.90, green: 0.24, blue: 0.28)
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)
}
// Context menu
struct ContextMenu: View {
var body: some View {
shCard(230, radius: 14) {
VStack(spacing: 0) {
ForEach(Array([("Copy", "doc.on.doc", false), ("Share", "square.and.arrow.up", false), ("Favorite", "star", false)].enumerated()), id: \.offset) { i, m in
HStack { Text(m.0).font(.system(size: 15)); Spacer(); Image(systemName: m.1).font(.system(size: 15)) }.foregroundStyle(.primary).padding(.horizontal, 14).padding(.vertical, 11)
Divider()
}
HStack { Text("Delete").font(.system(size: 15)); Spacer(); Image(systemName: "trash").font(.system(size: 15)) }.foregroundStyle(shRed).padding(.horizontal, 14).padding(.vertical, 11)
}
}
}
}
iOS 17 · No dependencies
Dependencies
- SwiftUI
- No external dependencies
Requires iOS 17


