Skip to content
Scan Search preview
Rendered from the SwiftUI source on this page.

Scan Search

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

A search bar with a barcode scanner.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

SearchScan.swift
// Scan Search · syxUI · https://syxui.dev/components/search-scan
// Free in any project. Keep this line and credit syxUI where a person can read it.

import SwiftUI

func searchField(_ placeholder: String) -> some View {
    HStack(spacing: 8) { Image(systemName: "magnifyingglass").font(.system(size: 15)).foregroundStyle(.secondary); Text(placeholder).font(.system(size: 16)).foregroundStyle(.secondary); Spacer() }.padding(.horizontal, 12).padding(.vertical, 11).background(Color.primary.opacity(0.06), in: RoundedRectangle(cornerRadius: 12, style: .continuous))
}

struct SearchScan: View {
    var body: some View {
        HStack(spacing: 10) { searchField("Search or scan"); Image(systemName: "barcode.viewfinder").font(.system(size: 20)).foregroundStyle(.primary).frame(width: 44, height: 44).overlay(RoundedRectangle(cornerRadius: 12).stroke(Color.primary.opacity(0.15))) }.frame(width: 340)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17