Skip to content
Command Palette preview
Rendered from the SwiftUI source on this page.

Command Palette

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

A command-palette search.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

SearchCommand.swift
// Command Palette · syxUI · https://syxui.dev/components/search-command
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

// Command palette
struct SearchCommand: View {
    var body: some View {
        VStack(spacing: 0) {
            HStack(spacing: 8) { Image(systemName: "command").font(.system(size: 15)).foregroundStyle(.secondary); Text("Type a command or search…").font(.system(size: 15)).foregroundStyle(.secondary); Spacer() }.padding(14)
            Divider()
            ForEach(Array([("plus.square", "New Document"), ("folder", "Open Folder"), ("gearshape", "Settings")].enumerated()), id: \.offset) { _, c in
                HStack(spacing: 12) { Image(systemName: c.0).font(.system(size: 15)).foregroundStyle(.secondary); Text(c.1).font(.system(size: 14)); Spacer(); Image(systemName: "return").font(.system(size: 12)).foregroundStyle(.secondary.opacity(0.5)) }.padding(.horizontal, 14).padding(.vertical, 11)
            }
        }.frame(width: 320).background(Color(.systemBackground), in: RoundedRectangle(cornerRadius: 16, style: .continuous)).overlay(RoundedRectangle(cornerRadius: 16, style: .continuous).stroke(Color.primary.opacity(0.08), lineWidth: 1)).shadow(color: .black.opacity(0.06), radius: 12, y: 5)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17