Skip to content
Category Filters preview
Rendered from the SwiftUI source on this page.

Category Filters

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

Search with category pills.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

SearchCategories.swift
// Category Filters · syxUI · https://syxui.dev/components/search-categories
// 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))
}

// Category quick filters
struct SearchCategories: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 12) {
            searchField("Search")
            HStack(spacing: 8) { ForEach(Array([("All", true), ("Shows", false), ("Movies", false), ("People", false)].enumerated()), id: \.offset) { _, c in Text(c.0).font(.system(size: 13, weight: .medium)).foregroundStyle(c.1 ? .white : .primary).padding(.horizontal, 14).padding(.vertical, 7).background(c.1 ? Color.primary : Color.primary.opacity(0.06), in: Capsule()) } }
        }.frame(width: 340)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17