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

Search Scopes

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

Search with segmented scopes.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

SearchScopes.swift
// Search Scopes · syxUI · https://syxui.dev/components/search-scopes
// 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)

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))
}

// Scopes (segmented tabs)
struct SearchScopes: View {
    var body: some View {
        VStack(spacing: 14) {
            searchField("Search")
            HStack(spacing: 24) {
                VStack(spacing: 6) { Text("Trending").font(.system(size: 14, weight: .semibold)); Capsule().fill(seBlue).frame(width: 24, height: 2.5) }
                VStack(spacing: 6) { Text("Recent").font(.system(size: 14, weight: .medium)).foregroundStyle(.secondary); Capsule().fill(.clear).frame(width: 24, height: 2.5) }
                Spacer()
            }
        }.frame(width: 320)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17