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

Shortcut Menu

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

A menu with keyboard shortcuts.

Navigation · SwiftUI · iOS 17

  • navigation
  • swiftui

The actual source

MenuShortcuts.swift
// Shortcut Menu · syxUI · https://syxui.dev/components/menu-shortcuts
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

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

struct MenuShortcuts: View { var body: some View { menuCard(240) { VStack(spacing: 0) { ForEach(Array([("New", "⌘N"), ("Open", "⌘O"), ("Save", "⌘S"), ("Close", "⌘W")].enumerated()), id: \.offset) { i, s in HStack { Text(s.0).font(.system(size: 15)); Spacer(); Text(s.1).font(.system(size: 13, design: .rounded)).foregroundStyle(.secondary) }.padding(.horizontal, 14).padding(.vertical, 10); if i < 3 { Divider() } } } } } }
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17