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

Shortcut Tooltip

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

A tooltip showing a keyboard shortcut.

Feedback · SwiftUI · iOS 17

  • feedback
  • swiftui

The actual source

TooltipShortcut.swift
// Shortcut Tooltip · syxUI · https://syxui.dev/components/tip-shortcut
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let ttDark = Color(red: 0.15, green: 0.15, blue: 0.17)

struct TooltipShortcut: View { var body: some View { VStack(spacing: -2) { HStack(spacing: 6) { Text("Search").font(.system(size: 13, weight: .medium)).foregroundStyle(.white); Text("⌘K").font(.system(size: 12, design: .rounded)).foregroundStyle(.white).padding(.horizontal, 5).padding(.vertical, 1).background(.white.opacity(0.2), in: RoundedRectangle(cornerRadius: 4)) }.padding(.horizontal, 10).padding(.vertical, 8).background(ttDark, in: RoundedRectangle(cornerRadius: 9)); Image(systemName: "arrowtriangle.down.fill").font(.system(size: 11)).foregroundStyle(ttDark) } } }
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17