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

Search Bar

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

An in-chat search field with a Cancel action.

Chat · SwiftUI · iOS 17

  • chat
  • swiftui

The actual source

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

import SwiftUI

// Search-in-chat bar
struct ChatSearchBar: View {
    let blue = Color(red: 0.0, green: 0.47, blue: 1.0)
    var body: some View {
        HStack(spacing: 10) {
            HStack(spacing: 8) {
                Image(systemName: "magnifyingglass").font(.system(size: 15)).foregroundStyle(.secondary)
                Text("Search messages").font(.system(size: 16)).foregroundStyle(.secondary)
                Spacer()
            }
            .padding(.horizontal, 12).padding(.vertical, 9)
            .background(Color(.systemGray5), in: Capsule())
            Text("Cancel").font(.system(size: 16)).foregroundStyle(blue)
        }
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17