Skip to content
Match Highlight preview
Rendered from the SwiftUI source on this page.

Match Highlight

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

Results with highlighted matches.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

SearchHighlight.swift
// Match Highlight · syxUI · https://syxui.dev/components/search-highlight
// 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)

// Highlighted result row
struct SearchHighlight: View {
    var body: some View {
        VStack(alignment: .leading, spacing: 0) {
            ForEach(Array(["Design", "Designer", "Design System"].enumerated()), id: \.offset) { i, s in
                HStack(spacing: 12) { Image(systemName: "magnifyingglass").font(.system(size: 14)).foregroundStyle(.secondary); (Text("Design").foregroundColor(seBlue).fontWeight(.semibold) + Text(String(s.dropFirst(6)))).font(.system(size: 15)); Spacer() }.padding(.vertical, 11)
                if i < 2 { Divider() }
            }
        }.frame(width: 300)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17