Skip to content
No Results preview
Rendered from the SwiftUI source on this page.

No Results

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

A no-results state.

Inputs · SwiftUI · iOS 17

  • inputs
  • swiftui

The actual source

SearchNoResults.swift
// No Results · syxUI · https://syxui.dev/components/search-no-results
// 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))
}

// No results
struct SearchNoResults: View {
    var body: some View {
        VStack(spacing: 12) {
            searchField("xzy123").padding(.bottom, 10)
            Image(systemName: "magnifyingglass").font(.system(size: 30)).foregroundStyle(.secondary).frame(width: 72, height: 72).background(Color.primary.opacity(0.05), in: Circle())
            Text("No results found").font(.system(size: 16, weight: .semibold))
            Text("Try a different keyword or check your spelling.").font(.system(size: 13)).foregroundStyle(.secondary).multilineTextAlignment(.center)
        }.frame(width: 300)
    }
}
iOS 17 · No dependencies

Dependencies

SwiftUI
No external dependencies

Requires iOS 17