Skip to content
Profile Menu preview
Rendered from the SwiftUI source on this page.

Profile Menu

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

A profile action menu sheet.

Cards · SwiftUI · iOS 17

  • cards
  • swiftui

The actual source

ProfileMenuSheet.swift
// Profile Menu · syxUI · https://syxui.dev/components/sheet-profile-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)
}

// Profile menu sheet
struct ProfileMenuSheet: View {
    var body: some View {
        shCard(320, radius: 22) {
            VStack(spacing: 0) {
                HStack(spacing: 12) { Image("person_5").resizable().scaledToFill().frame(width: 48, height: 48).clipShape(Circle()); VStack(alignment: .leading, spacing: 2) { Text("Sarah Miller").font(.system(size: 16, weight: .semibold)); Text("sarah@example.com").font(.system(size: 13)).foregroundStyle(.secondary) }; Spacer() }.padding(16)
                Divider()
                ForEach(Array([("person", "View Profile"), ("gearshape", "Settings"), ("rectangle.portrait.and.arrow.right", "Sign Out")].enumerated()), id: \.offset) { i, m in
                    HStack(spacing: 12) { Image(systemName: m.0).font(.system(size: 16)).foregroundStyle(i == 2 ? shRed : .primary).frame(width: 24); Text(m.1).font(.system(size: 15)).foregroundStyle(i == 2 ? shRed : .primary); Spacer() }.padding(.horizontal, 16).padding(.vertical, 12)
                    if i < 2 { Divider() }
                }
            }
        }
    }
}
iOS 17 · 1 dependencies

Dependencies

SwiftUI
  • person_5 (image asset)

Requires iOS 17