Skip to content
Recent Searches preview
Rendered from the SwiftUI source on this page.

Recent Searches

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

A recent-searches list with clear.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

SearchRecent.swift
// Recent Searches · syxUI · https://syxui.dev/components/search-recent
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

let seBlue = Color(red: 0.0, green: 0.47, blue: 1.0)

// Recent searches list
struct SearchRecent: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 0) {
            HStack { Text("Recent Searches").font(.system(size: 13, weight: .semibold)).foregroundStyle(.secondary); Spacer(); Text("Clear").font(.system(size: 13, weight: .medium)).foregroundStyle(seBlue) }.padding(.bottom, 6)
            ForEach(["coffee beans", "espresso machine", "milk frother"], id: \.self) { s in
                HStack(spacing: 12) { Image(systemName: "clock.arrow.circlepath").font(.system(size: 15)).foregroundStyle(.secondary); Text(s).font(.system(size: 15)); Spacer(); Image(systemName: "arrow.up.left").font(.system(size: 13)).foregroundStyle(.secondary) }.padding(.vertical, 10)
            }
        }.frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17